• Hello,

    In the process of creating a new theme, I need to make changes to the loop. So, I went over to the documentation of the loop, and grabbed one of the examples, and changed it to what I want it to do.

    What I want to do is to first show the 1st latest post at the top. Then, I want to show the remaining x amount of latest posts in a totally different way.

    Here’s the code that I have:

    <?php
    $my_query = new WP_Query('showposts=1');
    while ($my_query->have_posts()) : $myquery->the_post();
    $do_not_duplicate = $post->ID;
    ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    
    <h2 class="post-title"><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <small><?php the_time('F jS, Y \a\t g:i A'); echo ' by '; the_author(); ?></small>
    
    <div class="entry">
    
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    
    </div>
    
    <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    
    </div>
    
    <?php endwhile; ?>
    
    <?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 class="post-title"><a href="<?php the_permalink(); ?>" title="Permanent Link to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a><h2>
    <small></small>
    
    <div class="entry"></div>
    
    <p class="postmetadata">
    
    </div>
    
    <?php endwhile; ?>
    
    <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>
    
    <?php else : ?>
    
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.
    
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    <?php endif; ?>

    This is the error I’m getting:

    PHP Fatal error: Call to a member function the_post() on a non-object in /home/xxxxx/public_html/xxxxx/xxxxx/wp-content/themes/xxxxx/index.php on line 9

    Any ideas on what the problem is, and how I can fix it?

    Thanks,
    Matt

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom “The Loop” Problems’ is closed to new replies.