• Hi. I’m editing a theme and I don’t know why WordPress changes content depending on the order INCLUDE statements.

    If I have this code in page.php:

    <?php get_header(); ?>
    
    	<div id="content_box">
    
    		<div id="left_box">
    
    			<?php include (TEMPLATEPATH . '/left_bar.php'); ?>
    
    		</div>
    
    		<div id="content" class="page">
    
    				<div id="content_inner">
    
    				<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    					<h1><?php the_title(); ?></h1>
    					<div class="format_text">
    <?php the_content('<p>Read the rest of this page &rarr;</p>'); ?>
    <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
    					</div>
    
    				</div>
    
    				<?php endwhile; endif; ?>
    
    		</div>
    
    	</div>
    
    <?php get_footer(); ?>

    I do not get the contents of the page! Instead I get the same content as the index.

    If I reverse the order and have include (TEMPLATEPATH . ‘/left_bar.php’); after the post loop, it works but that breaks my CSS.

    Is there a certain order I must respect in order to get the page loop to work?

Viewing 1 replies (of 1 total)
  • Thread Starter qtzlctl

    (@qtzlctl)

    ok, think I’ve nailed it. left_bar.php has this loop

    query_posts('showposts=3');
    					if (have_posts()) :
    						while (have_posts()) : the_post(); ?>
    						<li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li>
    		<?php
    						endwhile;
    					endif; ?>

    which seems to me that it’s checking for a post on the page before it can show the titles of the latest news. And since there’s no post on the page, it reverts to index.php. I devised this by voodoo, but at least I know the cause. Off to hacking some more.

Viewing 1 replies (of 1 total)
  • The topic ‘What is the right order for include tags?’ is closed to new replies.