Skip to content

Instantly share code, notes, and snippets.

@FriendlyWP
Created July 5, 2016 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FriendlyWP/8975567aafb3c1115e88db98c124c75f to your computer and use it in GitHub Desktop.
Save FriendlyWP/8975567aafb3c1115e88db98c124c75f to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment