WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Older/Newer entries links do not display Older/Newer entries (5 posts)

  1. bklowercase
    Member
    Posted 3 years ago #

    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:

    http://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.

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    try to use the 'paged' parameter within the query:

    http://codex.wordpress.org/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)); ?>
  3. bklowercase
    Member
    Posted 3 years ago #

    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...

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    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; } ?>
  5. bklowercase
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic