Support » Fixing WordPress » query posts — formatting issue on page

  • Resolved csleh


    I am trying to pull posts into a page. Have tried many different ways, but when it does work it seems to be pulling in the formatting of the single post template along with the data.
    This is what I am currently using on the page template:

       if (is_page('our-team')) {

    But instead of pulling in the content and showing in the div, it is pulling in extra divs, just like from the single post template.

    I have tried using an INCLUDEPATH, but if I first query the posts in the page template, I get 2 copies of every post. If I query the category within the team.php template, I get two copies of every post. One copy will be formatted correctly, the other will have the additional info from the single post template.
    The “team.php” template contains only:

    <?php while (have_posts()) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
    		<?php the_content(''); ?>
      <?php endwhile;?>

    How can I pull in post DATA, without also bringing in the single post template?
    (and I cannot change the single post template, since many pages use that.)

Viewing 1 replies (of 1 total)
  • This seems to be working:

       if (is_page('our-team'))  { ?>
    <?php $temp_query = $wp_query; ?>
    <?php query_posts('cat=12'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h3><?php the_title(); ?></h3>
    <p><?php the_content(); ?></p>
    <?php endwhile; ?>
     <?php }

    I believe the first two and last two lines are saying “if this is the our team page, do this stuff”
    The stuff in the middle is a temporary query, which doesn’t affect the main page content (ie no doubling of “the_content”, but two distinct contents). the endwhile is saying my temporary query is finished.

    If my above translation is incorrect please say so, I’m trying to learn.

    FYI — this code goes after the closing of the loop on the page.

Viewing 1 replies (of 1 total)
  • The topic ‘query posts — formatting issue on page’ is closed to new replies.