Forums

Issue with Loop/Content not showing on Home Page (8 posts)

  1. ALTexasGirl
    Member
    Posted 10 months ago #

    Hi -

    I'm having some issues with my blog and suspect that it might be the php code in my loop. I'm running multiple loops to display recent articles and latest results.

    I have specific widgets in my sidebar that are only supposed to show on the index page, but since modifying the theme, they will not display. Also, I tried adding a test conditional tag for display on the home page, but to no avail.

    If someone could help me out, I would really appreciate it! Although I've been playing around with WordPress for several years, I'm very much a newbie when it comes to custom loops.

    This is the code that I am currently using in my index file:

    <?php get_header(); ?>
    
    	<div id="page">
    
    		<div id="contentleft">
    
    <?php if ( $paged < 2 ) { // Do stuff specific to first page?>
    
    <?php include (TEMPLATEPATH . '/features.php'); ?>
    
    			<div id="content">
    
    <h2 class="darkgreen">CONTENT</h2>
    <div class="homep">
    CONTENT
    </div>
    
      <h2 class="black">FIRST LOOP SECTION</h2>
    <div class="homep">
        <?php
        	$otherPosts = new WP_Query();
        	$otherPosts->query('showposts=3&cat=199');
        	while($otherPosts->have_posts()) : $otherPosts->the_post();
        ?>
    <strong><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></strong><?php the_excerpt(); ?>
    
        <?php endwhile; ?></div>
    
    <h2 class="lightgreen">SECOND LOOP SECTION</h2>
    <div class="related">
        <?php $temp_query = $wp_query; ?>
        <?php query_posts('category_name=wta-tennis&showposts=1'); ?>
        <?php while (have_posts()) : the_post(); ?>
    <?php if (get_post_meta($post->ID, post_thumbnail)) { ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, post_thumbnail, true); ?>" class="post-thum" alt="post thumbnail" /></a>
    <?php } ?><font size="+1"><strong><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></strong></font><br /><br />
    <?php the_excerpt(); ?><?php endwhile; ?>
    
            <strong>More Stories:</strong><br />
    <?php $posts = get_posts('category=83&numberposts=15&offset=1');
        foreach ($posts as $post) : start_wp(); ?>
            <ul><li><a href="<?php echo get_permalink() ?>"><?php the_title(); ?></a></li></ul>
            <?php endforeach; ?>
      </div>
    
    					<h2 class="lightgreen">CONTENT</h2>
    				<div class="related">
    CONTENT
    </div>
    
    <?php } else { // Do stuff specific to non-first page ?>
    
    			<div id="content">
    
    				<h2 class="sectionhead">Recent Articles</h2>
    
    <?php if (have_posts()) : while (have_posts()) : the_post();
    if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
    				<div class="post" id="post-<?php the_ID(); ?>">
    
    					<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    
    <?php if (get_post_meta($post->ID, post_thumbnail)) { ?>
    							<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, post_thumbnail, true); ?>" class="post-thum" alt="post thumbnail" /></a>
    <?php } ?>
    
    					<div class="entry">
    							<?php the_excerpt(); ?>
    
    					</div>
    
    				<div class="navigation">
    
    					<div class="alignleft">
    						<?php next_posts_link('&laquo; Previous Entries') ?>
    					</div>
    
    					<div class="alignright">
    						<?php previous_posts_link('Next Entries &raquo;') ?>
    					</div>
    
                    		</div>
    				</div>
    
    <?php endwhile; endif; ?>
    
    <?php } ?>
    
    			</div>
    
    <?php include (TEMPLATEPATH . "/sidebar1.php"); ?>
    
    		</div>
    
    <?php get_sidebar(); ?>
    
    	</div>
    
    <?php get_footer(); ?>

    Thanks! Feel free to let me know if you need any more information.

  2. bekabug
    Member
    Posted 10 months ago #

    just out of curiosity... why use $paged < 2 instead of is_front_page or is_home ?

  3. ALTexasGirl
    Member
    Posted 10 months ago #

    bekabug,

    I don't know why that tag was chosen as I didn't design the original template. However, I did change it just now to is_home, but it still is not making the conditional home content appear.

    Any suggestions for a fix?

  4. bekabug
    Member
    Posted 10 months ago #

    hmm...try is_front_page() instead

    I did leave off the () in my previous comment so double check the codex and make sure your syntax matches up

  5. ALTexasGirl
    Member
    Posted 10 months ago #

    Okay, I tried both of them, but no difference.

    This is what I currently am using:

    <?php if ( is_home()) { // Do stuff specific to first page?>

    Could a faulty php code in the loop be causing this problem?

    Thanks!

  6. bekabug
    Member
    Posted 10 months ago #

    going through your code i don't see anything that is jumping out at me where it tells the sidebar to do something specific. can you point it out to me?

  7. ALTexasGirl
    Member
    Posted 10 months ago #

    The main issue was a widget that I only wanted to display on the home page, but as the code is not working, I have it set to display site wide.

    However, I do have the following code (not as a widget) in the sidebar as a test:

    <?php if (is_home()) { ?>
    <p>test <a href="http://www.onthebaseline.com/">test</a>.</p>
    <?php } ?>

    Thanks!

  8. ALTexasGirl
    Member
    Posted 10 months ago #

    Anybody know a solution for this problem?

Reply

You must log in to post.

About this Topic