FriendlyWP
7/5/2016 - 8:26 PM

Shortcode to insert non-breaking spaces in WordPress content

Shortcode to insert non-breaking spaces in WordPress content

//[nbsp] shortcode
add_shortcode( 'nbsp', 'nbsp_shortcode' );
function nbsp_shortcode( $atts, $content = null ) {
    $a = shortcode_atts( array(
        'num' => 1,
    ), $atts );
    $content = str_repeat('&nbsp', $a['num']);
    return $content;
}