WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having a problem where my markup is rendered incorrectly (more space because of <br />) as WordPress adds <br /> everywhere theres a line break


  [y]Hello world[/y]
  [y]A test[/y]

In the handler for x the $content looks like

<br />
[y]Hello world[/y]
<br />
[y]A test[/y]
<br />

Am I suppose to strip out all the line breaks?


I notice that no line breaks


[y]Notepad++[/y] will not be rendered as a shortcode. I must have a space like

[x][y]Photoshop[/y] [y]Notepad++[/y][/x]


share|improve this question
How are you shortcode codes handled? Via a filter on the_content or using an actual registered shortcode? – t31os Apr 18 '11 at 11:27
its registered using add_shortcode() – JM at Work Apr 19 '11 at 1:33
up vote 1 down vote accepted

before you register your shortcode, add the filter to the content for unautop:

add_filter( 'the_content', 'shortcode_unautop' );

Do this also for the areas, maybe excerpt or widget, when your shortcode add to this areas.

share|improve this answer

When you are in the post editor, press CTRL + ENTER when you go to a new line. Doing that tells WordPress not to add a <br /> tag in your code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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