Support » Fixing WordPress » query_posts & multiple loops on my homepage

  • Resolved 3stripe

    (@3stripe)


    I’m having problems with the template below… query_posts should just output 2 news stories into the sidebar, but instead they are appearing withing the main loop as well…

    Can anyone help?

    Many thanks, 3stripe.

    <?php
    /*
    Template Name: Homepage with news
    */
    ?>
    <?php get_header(); ?>

    <div id=”page”>

    <div id=”logo”></div>

    <div id=”nav”><?php include ‘nav.php’; ?></div>
    <?php
    if ($parent_id == 3 || $parent_id == 6) {
    echo ‘<div id=”randomheader”></div>’;
    }
    else if ($parent_id == 19 || $parent_id == 28) {
    echo ‘<div id=”abstractheader1″></div>’;
    }
    else if ($parent_id == 25 || $parent_id == 25) {
    echo ‘<div id=”abstractheader2″></div>’;
    }
    else if ($parent_id == 26 || $parent_id == 33) {
    echo ‘<div id=”abstractheader3″></div>’;
    }
    else echo ‘<div id=”abstractheader2″></div>’;
    ?>

    <div id=”wrapper” class=”clearfix”>

    <div id=”subnav”>
    <?php query_posts(‘category_name=”news”&showposts=2’); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_date(‘d/m/Y’); ?>
    <?php $more = false; the_content(‘Continue reading…’, strip_teaser, ‘more_file’); ?>
    <?php endwhile; else: ?>
    <?php _e(‘Sorry, there was an problem loading the news stories’); ?>

    <?php endif; ?>
    </div>

    <hr />

    <div id=”content” class=”clearfix”>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php $content = split(“<!–more–>”, $post->post_content); ?>

    <div id=”title”>
    <h2><?php the_title(); ?></h2>
    </div>

    <div id=”leftcol”>
    <?php echo apply_filters(‘the_content’, $content[0]); ?>
    </div>

    <div id=”rightcol”>
    <?php echo apply_filters(‘the_content’, $content[1]); ?>
    </div>

    <?php endwhile; else: ?>
    <div class=”warning”>
    <?php _e(‘Sorry, no posts matched your criteria, please try and search again.’); ?>

    </div>
    <?php endif; ?>

    </div>

    <?php get_footer(); ?>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘query_posts & multiple loops on my homepage’ is closed to new replies.