• I have created a static Page (News) which I am using to display posts from a certain category (works correctly)
    • The Page uses a simple Template I created (news.php) with the following php code
      <?php while (have_posts()): the_post(); ?>
      <?php the_content();?>
      <?php endwhile;?>
    • The Page’s html includes a php include <?php include (TEMPLATEPATH . '/news_updates.php'); ?>
    • news_update.php is what grabs the posts with this code `<?php
      query_posts(‘cat=20’); ?>`
    • All of this works fine…my Static News page displays only the posts that fall into cat=20.
    • HOWEVER, for some reason, after displaying the posts as specified in the news_updates.php (title, body, time, etc), and closing out the display of that static News Page, below these posts it re-displays only the body from the cat 20 posts.
    • By adding comments into both the news_updates.php include and the news.php template, I have determined it the re-display of the cat20 posts’ body is generated from the news.php template

    Any ideas as to WHY this is displaying and how to fix it would be greatly appreciated.

    I guess another way to ask this question is, how, via a Template, do I query the content of a static page (which then correctly queries specific posts via a php include), WITHOUT having the Template query any posts whatsoever.

    eeek.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter trulyandy

    (@trulyandy)

    Any ideas out there?

    Thread Starter trulyandy

    (@trulyandy)

    Here is a link to the page in question:

    http://www.trulygoodsolutions.com/b11/news/

    Everything displays correctly, other than the duplication of the 2 posts’ bodies at the bottom of the page.

    Refer to above bullet point for how I have set this up.

    I think I understand how to use The Loop correctly, but maybe not!

    Not sure why you need this in news.php <?php include (TEMPLATEPATH . '/news_updates.php'); ?>

    Why not just put this in place of that include:
    <?php query_posts('cat=20'); ?>

    Thread Starter trulyandy

    (@trulyandy)

    Hi Michael,
    Thanks for your response!

    I actually don’t have the line you referenced in news.php.

    news.php is the template I am using for the News Static Page…
    and the code I have in news.php is simply:

    <?php while (have_posts()): the_post(); ?>
    		<?php the_content();?>
    
    	<?php endwhile;?>

    That code queries the html/php that I have entered in the WP admin Pages section for the News Static Page, correct?

    The error (if you want to call it that) is that the posts’ body is displayed a second time, below the Static Page content.

    It is being called, somehow, from the news.php template.

    Does that make sense?

    I am thrilled you looked into this and would really really love it if you could take a second look!

    Paste appropriate template(s) in a pastebin and report the link back here, please.

    Thread Starter trulyandy

    (@trulyandy)

    It seems you would have a plugin installed that allows PHP to be put in a post/page content.

    So news.php has a loop displaying posts. Then your page entered via Pages->Add new has code that includes new_items.php and new_items_php has a loop that seems to display posts from category 20.

    So a wild guess here would be to delete <?php the_content();?> in news.php but not sure how that will affect OTHER pages if they use news.php as their Page Template.

    Thread Starter trulyandy

    (@trulyandy)

    Thanks, Michael!

    • The good news is no other Page uses news.php as its template.
    • The bad news is that I tried removing <?php the_content();?> but unfortunately, when I remove that line, it seems that removes the call to retrieve the info that I entered into the Static Page ‘NEWS’
    • as you can see here: http://www.trulygoodsolutions.com/b11/news/
    • QUESTION: is there a line of code I can put into news.php that will retrieve the information that I have entered in the Static Page ‘NEWS’ but NOT retrieve actual posts?

    Thanks so much, I think we are almost there!

    Thread Starter trulyandy

    (@trulyandy)

    Hey Otto! Anyone! Anybody?? I need some WP masters to decipher this riddle!!

    Thread Starter trulyandy

    (@trulyandy)

    Wondering if anybody has any insight to this mysterious problem?

    Thread Starter trulyandy

    (@trulyandy)

    Can’t let this one slide…….looking for some help…..
    andy@trulygooddesign.com
    willing to pay for some help if necessary.

    thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Static Page displaying posts twice.’ is closed to new replies.