• Resolved bklowercase

    (@bklowercase)


    Hello all. I’ve tried at length to figure out this issue but haven’t been able to. I was not the initial “setter upper” of this wordpress site and have been appointed to solve some of the original issues never solved.

    In a nutshell, I have several pages that display posts from specific categories and the pagination navigation (cool rhyme!) does not work properly. When navigating to the next page of entries, the original latest entries display over again.

    I’m having this problem on several pages but here is an example for starters:

    https://www.lowercaseincart.com/WORK/intuit/exhibitions-events

    This page uses this line of code to display posts from two categories:
    <?php query_posts(array('category__in' => array(3,4))); ?>

    The page also uses navigation.php (which has not been altered from its original wordpress state) with this line of code in order to display the navigation links after the posts:

    <?php include ( TEMPLATEPATH . '/navigation.php' ); ?>

    I’m not a developer, but I’m xhtml/css fluent and decently proficient with editing and creating .php files for wordpress use. Just can’t seem to shake this issue!

    Any help would be appreciated! Thank you so much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • try to use the ‘paged’ parameter within the query:

    https://codex.www.ads-software.com/Function_Reference/query_posts#Pagination_Parameters

    change your line to this, for instance:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // pagination ?>
    <?php query_posts(array('category__in' => array(3,4), 'paged' => $paged)); ?>
    Thread Starter bklowercase

    (@bklowercase)

    Thank you so much. This fixed the issue. Can you tell me what the first line does and how you came up with it? For example, why is (get_query_var('paged') used twice and what is it doing? I tried it without that first line and it still seems to work the same way. I’d love to understand what it’s doing and why it works. Blech, I really need to learn my php syntax…

    the first line
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    gets the query variable ‘paged’

    – the way it is written is called a ternary operator, and is short for:

    <?php if( get_query_var('paged') ) { $paged = (get_query_var('paged')); }
    else  { $paged = 1; } ?>
    Thread Starter bklowercase

    (@bklowercase)

    Ahhh. php shorthand. Didn’t see that one coming. Thanks so much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Older/Newer entries links do not display Older/Newer entries’ is closed to new replies.