• Resolved newgeek

    (@newgeek)


    In my category (which can be seen from here https://newgeek.com.br/games/) I cal the last post, then I call the 2 posts before that. And then if you scroll down you’ll notice “Old News” that is where I call the last 10 posts of the category to show.

    As of now I call the 10 posts with:

    <?php  global $post;
    				 $cntr = 1;
                     $myposts = get_posts('category=2&numberposts=10&order=des');
                     foreach($myposts as $post) :
                     setup_postdata($post);?>
    
    Call images and titles and etc
    
                  <?php $cntr++; ?>
                <?php endforeach; ?>

    And I can’t get pagination to work. I’m almost sure that it’s because I’m using get post while I should use a Loop.

    Well the thing is, I have been trying using loops and still it won’t work. I either find that the “https://newgeek.com.br/games/page/2/&#8221; didnt work or it showed me the same thing (and sometimes screws the other loop I have up there at the beginnning to call the 3 posts…).

    Even funnier is that my pagination code for the Search is working…

    ` <?php
    global $wp_query;
    $big = 999999999; // need an unlikely integer
    echo paginate_links( array(
    ‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ),
    ‘format’ => ‘?paged=%#%’,
    ‘current’ => max( 1, get_query_var(‘paged’) ),
    ‘total’ => $wp_query->max_num_pages ) ); ?> `

    I’m not good with php or wordpress loops, but I get by… The thing is that it’s being very stressful to try and try and nothing seems to work. If you guys could give me some insight on wich code to use for the loop that will work with pagination I’d be very thankful.

    What I want to do is make a way that people can acess older posts of the category. Showing 10 per time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You can receive urgent support at https://jobs.wordpress.net

    Thread Starter newgeek

    (@newgeek)

    I found my own solution for anyone interested I’m using this:

    <?php
    		$paged = get_query_var('paged') ? get_query_var('paged') : 1;
    		query_posts('cat=6&paged='.$paged.'&post_per_page='.get_option('posts_per_page'));
    		?>
    
                <?php while (have_posts()) : the_post(); ?>

    Then the call for thumbnail, title, etc…The endwhile

    <? endwhile ?>

    And this to get the pagination

    <?php
    		global $wp_query;
    		$big = 999999999; // need an unlikely integer
    		echo paginate_links( array(
    			'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    			'format' => '?paged=%#%',
    			'current' => max( 1, get_query_var('paged') ),
    			'total' => $wp_query->max_num_pages 	) ); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Help] Category Recent Posts Pagination’ is closed to new replies.