Back to Top

How to Fix Category Pagination in WordPress

Nowadays I am working on one site which is in WordPress and site will have multiple posts from the single category and per page maximum 10 posts will be displayed. If post within a category is more than 10, pagination comes.

so for that I have created one function wph_pagination which is working fine for other sites but it is not working here.

Pagination links are coming but when I am clicking the link, I will get “404 page not found ” error or same content will be displayed on all the page links.

Lets have a look into the code i have written:

query_posts( array( 'cat' =>$cat , 'order' => 'DESC' ) );
while(have_posts()) : the_post();
	/* my content goes here */
endwhile;
// Pagination function called here

Here I have called query_post function because I want to get multiple posts from the specific category.

I have just added one line which I forgot to add before query_posts and because of it pagination was not working.
After adding following line of code, pagination working fine.

so Lets check what changes I have done :

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

That’s it.

Further Read:

Pagination when getting posts from category in WordPress
Pagination in CodeIgniter
To use Pagination in Joomla

I hope this post will help you. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (1)

  1. hi.
    thanks for this good article.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

The Readers’ Poll – January 2013

Posted on 6 years ago

Bhumi

Function handling Functions in PHP

Posted on 7 years ago

Bhumi

How to use WebService in PHP

Posted on 4 years ago

Bhumi

How to define PHP Magic constants

Posted on 7 years ago

Zinal

How to setup Facebook PageTab Popup

Posted on 6 years ago

Bhumi

Hello world

Updated 1 month ago

Nick Carter

In depth Understanding of Laravel Core

Updated 3 months ago

Bhumi

ECMAScript 6 New Features – 2

Updated 1 year ago

Bhumi

The Reader’s Poll – June 2015

Posted on 4 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 5 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 6 years ago

Bhumi