Skip to content
UFO Performance Marketing

Where intelligence is put to the test.

HomeServicesCase StudiesBlogAboutContact Us
Menu
HomeServicesCase StudiesBlogAboutContact Us
WordPress · Oct 16, 2014

WordPress Pagination in Custom Loop

WordPress Pagination in Custom Loop
JC
John Crenshaw
Oct 16, 2014· Updated Oct 22, 2026

When you use a custom loop in WordPress, pagination may not work as expected. You may see only the first page of posts, regardless of which page you select. I often use WordPress as a content management system for client projects and encounter this problem with custom loops. Here is the solution:

Update query_posts with the proper query vars

The solution to this problem is pretty simple. You need to tell WordPress to use the "paged" query variable in your custom loop, otherwise it's ignored. If you're using the query_posts function for your custom loop, the easiest way to do this is like so:

1
2
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('paged=' . $paged . '&cat=76'); // show posts in category 76 with pagination enabled

In this example, we first test to see if the "paged" query variable is set using the get_query_var function, which will return false if it's not set. If it is set, we'll set $paged equal to the value of that query variable and if not, we'll set it equal to 1.

Then we initialize our custom loop using the query_posts function by setting "paged" equal to our $paged variable so that WordPress grabs the current page from the URL and displays the appropriate list of posts for that page.

I'm also looping through the posts in category #76 in this example, which is only there for illustrative purposes. That's all there is to enabling pagination in custom WordPress loops.

WordPress

Get the latest from UFO

Keep reading

More from the blog

All Posts →
ExpressionEngine vs. WordPress - Final Thoughts
WordPress

ExpressionEngine vs. WordPress - Final Thoughts

What I like about ExpressionEngine when compared to WordPress and my final thoughts on the commercial CMS from EllisLab.

John Crenshaw · Oct 13, 2018
Wordpress $post Object Quick Reference
WordPress

Wordpress $post Object Quick Reference

This quick reference / cheatsheet is for the WordPress $post object. This object contains a bunch of info specific to each WordPress post. Scroll down for the complete table of object properties.

John Crenshaw · May 15, 2015
Remove "Briefly Unavailable for Scheduled Maintenance" Message
WordPress

Remove "Briefly Unavailable for Scheduled Maintenance" Message

If you've been keeping on top of your WordPress updates using the automatic upgrade feature, you may have run into a problem immediately after upgrading.

John Crenshaw · Dec 10, 2014

Want results like these?

Let's talk about where you are, where you want to go, and the smartest way to get there.

Contact Us
UFO

Where intelligence is put to the test.

  • Home
  • Services
  • Case Studies
  • About
  • Partners
  • Testimonials
  • Projects
  • Blog
  • Careers
  • Contact Us

Offices

  • Cincinnati, OH
  • Columbus, OH
  • Portland, OR
  • (513) 549-7355
Contact Us
Google 5.0 five star rating Google Ads Premier Partner 2026
© Copyright 2026 UFO Marketing. All rights reserved. Privacy Policy | Terms of Use