WordPress.org

Ready to get started?Download WordPress

Forums

Use of query_posts on Main Index Template forces Category Template (1 post)

  1. Spamboy
    Member
    Posted 7 years ago #

    I am having a strange issue concerning query_posts in my Main Index Template. When I use the parameter "cat=", code in my sidebar that detects the current page is saying I am viewing a Category Archive while viewing my Main Index (index.php)

    Below is the code for my Main Index Template (index.php):

    <?php get_header(); ?>
    
    <?php if (is_home()) { ?>
    	This is the home page
    
    <?php } elseif (is_category()) { ?>
    	This is the category page
    
    <?php } ?>
    
    <?php query_posts('cat=100'); ?>
    
    <?php if (have_posts()) : ?>
    	<?php while (have_posts()) : the_post(); ?>
    		<?php $buttercup_loopcount++; ?>
    		<?php if ($buttercup_loopcount != 1) { ?>
    			<hr width="75%" size="2" />
    		<?php } ?>
    		<h3><?php the_title(); ?></h3>
    		<p class="entry-date"><?php the_time('F j, Y') ?>
    
    		<?php the_content('Read the rest of this entry &raquo;'); ?>
    	<?php endwhile; ?>
    <?php else : ?>
    	<h1>NOT FOUND</h1>
    <?php endif; ?>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    The If...Else statement containing is_home() and is_category() is also in my Sidebar Template (sidebar.php).

    When viewing the the Main Index, right below the header it will say "This is the home page". The sidebar contradicts this and says "This is the category page".

    Why wouldn't the sidebar code be behaving properly?

Topic Closed

This topic has been closed to new replies.

About this Topic