• Hi everyone,

    Well, it seems that this is a common problem with query_posts (i’ve seen many threads on Google, but none of them solved my problem).

    I’ve added a line in my index.php page :
    <?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; ?>
    the problem is half solved, i can get to my older posts, but this time i have all my posts on the same page(no navigation anymore).
    here is the link : https://blog.himstudio.com/?cat=4

    Can anyone help men on this, i’m new at WordPress (used to work with Joomla).
    Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)
  • I think you are halfway there… you assign the proper stuff to $paged

    Do you now include the $paged variable into your query posts?

    (also, page should be paged, and I think your parenthesis might be wacky — I believe you use ‘page’ on page templates, else ‘paged’)

    <?php
    $paged = ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 );
     query_posts( array(
          'posts_per_page' => 5,
          'cat' => '10',
          'paged' => $paged
     ));
    ?>

    or simply

    <?php query_posts( array(
          'posts_per_page' => 5,
          'cat' => '10',
          'paged' => ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 ),
     ));
    ?>

    https://vudu.me/10f
    My little writeup about using it

    Thread Starter himstudio

    (@himstudio)

    I’m kinda confused ! here is my index.php can you take a look at it please? Something might be wrong on it ??

    [Code moderated as per the Forum Rules. Please use the pastebin]

    https://scribu.net/wordpress/wp-pagenavi/right-way-to-use-query_posts.html

    The codex for query posts links here

    (Queries aren’t my strength), but reading that article, all I can suggest is to change both ‘page’ to ‘paged’

    <?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; ?>

    In that line, as your file is an index, and not a page

    Thread Starter himstudio

    (@himstudio)

    all I can suggest is to change both ‘page’ to ‘paged’
    <?php $paged = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1; ?>
    In that line, as your file is an index, and not a page

    I’ve tried this, but i got back to where i’ve started. When i try to get the second page i get the error message that says that the page is not found…
    i don’t get it !

    You can give your permalinks a reset by going to the settings->permalinks page and hitting save. Worth a try! That has often cleared up 404 errors for me

    Thread Starter himstudio

    (@himstudio)

    the line
    <?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; ?>
    shows at least all the articles.

    right, but it doesn’t paginate

    Thread Starter himstudio

    (@himstudio)

    many proposed solutions talk about an array..in my index file i don’t see any array ! could this be the source of the problem ?

    if you’d like, throw your code back up into a pastebin and report the link here. Maybe someone else can take a better look than me.

    The array really does the same thing as the way your code is written

    It’s cleaner, and easier to look at. Your code should provide the same functionality.

    Thread Starter himstudio

    (@himstudio)

    indeed, i added an array to my code…it does the same thing and the problem is still the same.. thank you Rev.Voodoo for your help ??

    Thread Starter himstudio

    (@himstudio)

    this is my index file index.php

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Query_posts page navigation problem (3.2.1)’ is closed to new replies.