Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other WordPress: Pagination on a custom query on Homepage

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #34615
    vnvillar
    Participant

    Hello again, Guys!

    Hope you’re all having a grand time. I wanted to have a pagination on a custom query that I wanted to show at the bottom of my homepage. Any ideas guys on how to do this? Please see attached link of my design that I wanted to look like

    http://i.imgur.com/SJ0AY.png

    Thank you advance :)

    All the best,

    Val

    #88387
    TheDoc
    Member
    #88388
    vnvillar
    Participant

    Thank you TheDoc! I did stumbled upon that blog and I can’t seem to understand it (forgive me I’m not that advance in WordPress :D )

    Here’s the code I’m using in my index.php file



    query('cat=5&showposts=10'); ?>
    have_posts()) : $recent->the_post(); ?>



    Can you tell me how it should it be?

    Thank you so much :)

    Val

    #88390
    TheDoc
    Member

    Based on your image you would have to do something like this for your query:

    
    'posts_per_page' => 6,
    'paged' => get_query_var('paged')
    );
    query_posts( $args ); ?>








    And then you’ll need to add in the pagination after your endwhile.

    #88429
    vnvillar
    Participant

    Ah.. ok will try the code and will let you know the output. Thanks TheDoc! :)

    #88441
    vnvillar
    Participant

    Hi TheDoc,

    I tried using the code you gave me, also added post navigation link, but the pagination doesn’t seems to be working?

    Here’s the code snippet:

    
    'posts_per_page' => 3,
    'paged' => get_query_var('paged')
    );
    query_posts( $args ); ?>



    ">






    Am I missing something?

    Thanks!

    Val

    #88494
    TheDoc
    Member

    What happens when you click ‘next’?

    #88496
    vnvillar
    Participant

    It just displays the same posts :| but I can see the site url changed to ?page=2 though. Am I missing anything?

    #88497
    TheDoc
    Member

    Instead of:
    'paged' => get_query_var('paged')
    …try:
    'paged' => get_query_var('page')

    #88524
    vnvillar
    Participant

    Ok got it. Will update you the output :)

    Thanks Doc!

    #88526
    vnvillar
    Participant

    Hi Doc,

    It didn’t worked :|

    #88555
    TheDoc
    Member

    Okay, mucho frustration!

    Let’s try simplifying the loop and getting rid of the ‘else’ stuff and we’ll add a reset:

    
    
    $args = array(
    'posts_per_page' => 3,
    'paged' => get_query_var('paged')
    );

    // The Query
    query_posts( $args );

    // The Loop
    while ( have_posts() ) : the_post(); ?>

    ">




    posts_nav_link();

    // Reset Query
    wp_reset_query();

    ?>
    #88557
    vnvillar
    Participant

    Hehe true, what would I do without CSS Tricks! :)

    Got it, will try again with the code you gave me.

    Thanks Doc!

    Val

    #88588
    vnvillar
    Participant

    Woohoo! Finally got it working, apparently I also have a main loop at the top part of my homepage I forgot to add on that loop. Thanks so much Doc for the help, really appreciate it!

    Thank you CSS Tricks! :D

    Best,

    Val

    #88590
    TheDoc
    Member

    But of course – should’ve asked about another loop! Glad you got it sorted.

Viewing 15 posts - 1 through 15 (of 18 total)
  • The forum ‘Other’ is closed to new topics and replies.