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'm trying to style a form on a website, but I'm hitting a snag. Wordpress is automatically generating <br> tags when I directly edit the HTML for pages.

What I've got is this:

<legend>* Your name:</legend>
<ul class="singleLine">
        <input id="FName" type="text" name="FName" size="20" maxlength="20" />
        <label for="FName">First</label>
        <input id="LName" type="text" name="LName" size="30" maxlength="40" />
        <label for="LName">Last</label>

...all mashed together into a single line because WP wants to generate <br> tags all over the place if I don't. I can deal with that, but I'm actually still getting <br> tags generated directly after each<span> tag in the resulting page even with all of the HTML smooshed together on one line. How do I get rid of those?


Edit: Here's the portion of the layout that generates the page content.

<div id="main-content">
    <?php while( have_posts() ) : the_post() ?>
        <h1 id="pagetitle"><?php the_title(); ?></h1>
        <div class="pagecontent">
            <?php get_the_content() ?>
    <?php endwhile ?>   

replacing get_the_content() with the_content() renders properly.

share|improve this question
Wait: you have form field HTML tags directly in the page content? How are you doing that? – Chip Bennett May 24 '12 at 20:49
up vote 3 down vote accepted

Try using get_the_content(); in your page template loop instead of the_content();

EDIT 05/24/2012 - Try this:

<div id="main-content">
    <?php while( have_posts() ) : the_post() ?>
        <h1 id="pagetitle"><?php the_title(); ?></h1>
        <div class="pagecontent">
            <?php echo get_the_content(); ?>
    <?php endwhile ?>   

P.S. You will also need to consider the rest of your more "normal" wordpress pages through out your site.

You don't want ALL of your pages functioning like that. I would create a page template for the pagess that need to function this way, the rest of your pages should use the normal page.php template.

Learn more on page templates.

share|improve this answer
using get_the_content(); doesn't render anything at all... the div I placed my content in is simply blank when I use that function. Any other ideas/fixes for that? Thanks! – Benjamin Kovach May 23 '12 at 16:15
@BenjaminKovach please update your question with the code for your page template, or more specifically the loop within your page template, before I can be of further assistance. – Michael Ecklund May 23 '12 at 18:51
@BenjaminKovach provided an update to my solution. – Michael Ecklund May 24 '12 at 18:33
Thanks! That did fix it. – Benjamin Kovach May 25 '12 at 14:59

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.