1

I have a simple function in functions.php that creates a custom shortcode:

function my_line_break() {
    return "<br>";
}
add_shortcode( 'new line', 'my_line_break' );

Now, I don't know if this happened after upgrading to 4.4 but it's not longer working and pages just render [new line] in plain text.

Anyone can help with this? I looked at https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/ but I'm not sure it relates?

P.S. I know this wouldn't be the right way to handle line breaks, but I did it as a way to make life simpler for my customer (so as a little side question, if there is a valid and simple to use alternative, could you please let me know it so I can also bypass this problem completely?).

2
  • 1
    Please try to rename your shortcode to 'new_line' - maybe the space breaks it. – fischi Dec 14 '15 at 9:45
  • Thanks! That was it! I wonder if this is related to changes to the API that I linked. Anyway, please post it as an answer and I'll mark it as correct! Cheers. – jj_ Dec 14 '15 at 10:38
2

Converting the comment to an answer,

please rename your Shortcode to not contain spaces (new_line):

function my_line_break() {
    return "<br>";
}
add_shortcode( 'new_line', 'my_line_break' );
1

Your shortcode name is incorrect . Shortcode API - WordPress Codex

So you can write like :

function my_line_break() {
    return "<br>";
}
add_shortcode( 'newline', 'my_line_break' );

Then :

[newline]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.