Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I just fixed the problem of my featured posts section displaying on every index page instead of just the first one. This, of course, created a brand new problem. The first page looks fine; my featured posts are all where they should be and the loop below doesn't include any repeat posts. But then I click on "older entries" at the bottom of the page and page two contains the first eight posts from the loop. Page three contains the same eight posts, as do pages four, five, six, and presumably all of them.

Here's page two, where the problem starts. What do I need to add or take out in order to fix it?

Thanks in advance.

EDIT: I think I have an idea of where the problem is, but not how to fix it. Everything seems to work fine until I add in the query_posts to offset the main loop by 4, since those posts are displayed up in the feature area. It seems that when I go to page two and beyond, every page is starting from that offset of four instead of continuing on to display the next batch of posts. If I take out the query, it works fine, except for the fact that I have duplicate posts in the loop.

share|improve this question
    
Hi, did you figur out how to fix this problem? –  mgPePe Aug 17 '11 at 14:48

3 Answers 3

How many calls to query_posts() are you making? If you're making more than one, then you need to replace one of them with a call to WP_Query, or get_posts() - and you need to call wp_reset_query() between the Loops.

share|improve this answer

Try this one instead (more native, closer to core): get_adjacent_post() - link ... for a more indepth look at how it works, look at my repo @github

share|improve this answer
    
Please correct me if I'm wrong, but this looks like it would be useful for finding the next single post on a single post page. I need something to fix the links on my main index page so they'll stop returning the same eight posts. –  InkAndPixelClub Feb 21 '11 at 19:35
    
Download the plugin from the repo and add the template tag below or above (outside) your loop-code. You'll see it working, like described in the readme.textile file in the repo (index page). On single post pages you need to include it inside the loop and no first/last will work there. –  kaiser Feb 21 '11 at 20:01
    
I must be doing something wrong. I put in the template tag on the index page, but I'm only getting a fatal error message saying it's an undefined function. –  InkAndPixelClub Feb 21 '11 at 21:08
    
I decided that the easiest thing would be to just set up a new category for the other posts I wanted the main loop to skip and add an additional line of code to have it skip that category. I wanted to avoid adding a new category, but everything else I tried was just breaking my site more and more. I appreciate the help regardless. –  InkAndPixelClub Feb 21 '11 at 22:31
    
undefined function? Have you added the plugin to your plugin folder? –  kaiser Feb 21 '11 at 23:33

Too less space in a comment: Try the following in your functions.php file (of your theme). Plugin must be active and within it's own folder inside /root/wp-content/plugins/$folder. You have to specify the name of your plugin folder inside the function

    function check_deamon_class() {
        // check if plugin is active
        // ENTER NAME OF FOLDER HERE:
        $folder = 'example_easy_pagination_deamon'; // Enter the name of the folder in which you got the plugin files here
        $plugin_info = 'The pagination deamon plugin is';
        $plugin_info .= !is_plugin_active( $folder ) ? ' not active.' : ' active.'; 
        // check if the class can be loaded
        $class_info = '<br />';
        $class_info .= 'The deamon class';
        $class_info .= !class_exists('PaginationDeamon') ? ' was not found.' : ' was found.';
        $deamon = new oxoPaginationDeamon;
        $range = 5;
        $deamon_test = $deamon->links( $range );
        $info = '<div style="position: absolute; display: block; width: 200px; height: 100px; background-color: #000; color: #fff; top: 0; left: 0;"><p>'.$plugin_info.$class_info.'</p><br />'.$deamon_test.'</div>';
        return print $info;
    }
    if ( function_exists('wp_footer') ) {   
      add_action( 'wp_footer', 'check_deamon_class' ); 
    } 
    else { 
      echo '<div style="position: absolute; display: block; width: 200px; height: 100px; background-color: #000; color: #fff; top: 0; left: 0;"><p>Your Theme has no "wp_footer()" hook to attach the test.</p></div>';
    }

Tell me what note you receive within a black box with white text in the upper left of your page.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.