• Resolved toxiccosmos

    (@toxiccosmos)


    Hey everyone,

    So, I’m using $count to display my index in variable post styles (full width latest post highlight followed by left and right columns for the rest).
    https://victoriaarriaga.com/test_site/

    The code: https://pastebin.com/mDw0jSF1

    The problem I’m having is that my navigation isn’t working correctly. It is currently displaying “Page 1 of 1” despite the fact that there are enough posts for two pages.

    I’m currently using the plugin WP-PageNavi for my navigation, but I believe my problem lies with the way I have it nested within the loop. I was hoping someone could take a look at it and let me know if that’s the case.

    It might be important to note that I also intend to put the navigation at the bottom of the page as well, so any needed special pointers in accomplishing that would be appreciated. ??

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter toxiccosmos

    (@toxiccosmos)

    Update: I’ve also tried replacing the PageNavi code with the conventional

    <?php
    next_posts_link( 'Older Entries', $the_query->max_num_pages );
    previous_posts_link( 'Newer Entries' );
    ?>

    and have tried moving it around within my loop to see if I have any luck in getting this to work properly, but haven’t been able to. I’m not very proficient in PHP, so I’m really at a loss now and would really appreciate some advice from those of you more knowledgeable than I.

    Thanks.

    Thread Starter toxiccosmos

    (@toxiccosmos)

    Thanks for the reply, alchymyth.

    That’s what I thought I was doing (adding the paged parameter) with:
    $the_query = new WP_Query( array( 'posts_per_page'=> 5, 'paged' => $paged ) );

    But I see my mistake.

    I’m not sure I’ve implemented it properly, but I now have:

    <?php $count = 0;
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
    'posts_per_page' => 5,
    'paged' => $paged
    );
    $the_query = new WP_Query($args);
    ?>

    If I’m not mistaken, that defines $paged and then sets it to use in the query, right? Though I don’t see that it has fixed the issue I’m having. Page 2 still seems to be the same as the first. :/

    Thread Starter toxiccosmos

    (@toxiccosmos)

    Here is an update of the entire Index:
    https://pastebin.com/SHZsLeJT

    try with ‘page’:

    <?php $count = 0;
    $paged = (get_query_var('page')) ? get_query_var('page') : 1;
    $args = array(
    'posts_per_page' => 5,
    'paged' => $paged
    );
    $the_query = new WP_Query($args);
    ?>

    if that also won’t work, please post the full code of the template; https://codex.www.ads-software.com/Forum_Welcome#Posting_Code

    Thread Starter toxiccosmos

    (@toxiccosmos)

    That worked perfectly! Thank you! I’ve been banging my head for the past two weeks trying to figure it out and you’ve fixed it for me in two hours. ?? I really appreciate it. Thanks ??

    Thread Starter toxiccosmos

    (@toxiccosmos)

    Just a quick note to anyone trying to get their navigation to work, I had to use the following code to get the navigation to correctly display the current page being viewed:

    <?php $count = 0;
    if( get_query_var( 'paged' ) )
    	$my_page = get_query_var( 'paged' );
    else {
    	if( get_query_var( 'page' ) )
    		$my_page = get_query_var( 'page' );
    	else
    		$my_page = 1;
    	set_query_var( 'paged', $my_page );
    	$paged = $my_page;
    }
    	$paged = (get_query_var('page')) ? get_query_var('page') : 1;
    	$args = array(
    		'posts_per_page' => 5,
    		'paged' => $paged
    	);
    	$the_query = new WP_Query($args);
    ?>

    I found this here: https://www.ads-software.com/support/topic/wp-pagenavi-with-custom-query-and-paged-variable?replies=2

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Nesting navigation within a $count loop’ is closed to new replies.