Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress custom query pagination

I have a WordPress site, where on the main page I list the content from more categories.

My question is, is there a plugin where I can paginate the results from a category? I mean something like $this->plugin_paginate('category_id'); or smth?

Best Regards,

like image 693
Uffo Avatar asked Jul 21 '26 08:07

Uffo


1 Answers

If you're using the standard Wordpress loop, even with a query_posts for a category, pagination is automatic with the usual posts_nav_link. Are you trying to paginate for more than one query and more than one category on the same page?

Edit 11/20: I use this in several different places on one page to show the latest post in a category:

<?php
$my_query = new WP_Query('category_name=mycategory&showposts=1');
while ($my_query->have_posts()) : $my_query->the_post();
?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php endwhile; ?>

That link then goes to a category page that paginates for that category: Category Templates « WordPress Codex

I don't know how to paginate different categories on the same page. Must be possible. Maybe ask in the Wordpress forums.

like image 112
markratledge Avatar answered Jul 23 '26 03:07

markratledge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!