1

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:

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

...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?

Thanks!

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() ?>
        </div>
    <?php endwhile ?>   
</div>

replacing get_the_content() with the_content() renders properly.

  • 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
3

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(); ?>
        </div>
    <?php endwhile ?>   
</div>

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.

  • 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

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.