Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I had some code in a template file. When I pasted it from the backend's post panel (HTML tab) as a post, and retrieved it as custom loop, the code didn't output well.

Any suggestions?

Adding them as posts:

<?php
/**
 * Template Name: Lyrics Page
 * @package WordPress
 * @subpackage Prominent
 * @since Prominent 1.0
 */
get_header(); ?>
<div id="tagline">
    <div class="container">
        <?php // Run main loop (The Loop). ?>
        <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <div class="content0">
        </div>
        <?php endwhile; ?>
    </div><!-- .container -->
</div><!-- #content-bottom -->
<div id="content">
    <div class="container">
        <div id="mainbar">
            <div id="accordions-top">
            <?php $custom_posts = new WP_Query(); ?>
            <?php $custom_posts->query('category_name=Lyrics'); ?>
            <?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
                <?php the_content(); ?>
            <?php endwhile; ?>
            </div>
        </div><!-- #mainbar -->
        <?php get_sidebar(); ?>
    </div><!-- .container -->
</div><!-- #content-bottom -->
<?php get_footer(); ?>

Directly on the file:

<?php
/**
 * Template Name: Lyrics Page
 * @package WordPress
 * @subpackage Prominent
 * @since Prominent 1.0
 */
get_header(); ?>
<div id="tagline">
    <div class="container">
        <?php // Run main loop (The Loop). ?>
        <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <div class="content0">
            <?php the_content(); ?>
        </div>
        <?php endwhile; ?>
    </div><!-- .container -->
</div><!-- #content-bottom -->
<div id="content">
    <div class="container">
        <div id="mainbar">
            <div id="accordions-top">
                            <div class="basic" style="float:left; margin-left: 2em;" id="list1e">
                        <a>There is one obvious advantage:</a>
                        <div>
                            <p>
                                You've seen it coming!<br/>
                                Buy now and get nothing for free!<br/>

                                Well, at least no free beer. Perhaps a bear,<br/>
                                if you can afford it.
                            </p>
                        </div>
                        <a>Now that you've got...</a>
                        <div>
                            <p>
                                your bear, you have to admit it!<br/>

                                No, we aren't selling bears.
                            </p>
                        </div>
                        <a>Rent one bear, ...</a>
                        <div>
                            <p>
                                get two for three beer.
                            </p>
                            <p>

                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>

                                And now, for something completely different.<br/>
                                And now, for something completely different.<br/>
                                Period.
                            </p>
                        </div>
                </div>
            </div>
        </div><!-- #mainbar -->
        <?php get_sidebar(); ?>
    </div><!-- .container -->
</div><!-- #content-bottom -->
<?php get_footer(); ?>

Output of the post when I add via admin panel:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />

  <title></title>
</head>

<body>
  <div id="content">
    <div class="container">
      <div id="mainbar">
        <div id="accordions-top">
          <div class="basic" style="float:left; margin-left: 2em;" id="list1e">
            <a>There is one obvious advantage:</a>

            <div>
              <p>You&rsquo;ve seen it coming!<br />
              <br />
              Buy now and get nothing for free!<br /></p>

              <p>Well, at least no free beer. Perhaps a bear,<br />
              <br />
              if you can afford it.</p>
            </div>

            <p><a>Now that you&rsquo;ve got&hellip;</a></p>

            <div>
              <p>your bear, you have to admit it!<br /></p>

              <p>No, we aren&rsquo;t selling bears.</p>
            </div>

            <p><a>Rent one bear, &hellip;</a></p>

            <div>
              <p>get two for three beer.</p>

              <p>And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br /></p>

              <p>And now, for something completely different.<br />
              <br />
              And now, for something completely different.<br />
              <br />
              Period.</p>
            </div>
          </div>
        </div>
      </div><!-- #mainbar ==ý-->
    </div>
  </div>
</body>
</html>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Finally, figured out, I needed this:

remove_filter('the_content', 'wpautop');

share|improve this answer

Your Answer

 
discard

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.