1. Home
  2. /
  3. Web Design & Development
  4. /
  5. WordPress
  6. /
  7. How to fix the pagination issue or 404 page after Yoast – dropping of post category slug from the url?

How to fix the pagination issue or 404 page after Yoast – dropping of post category slug from the url?

How to fix the pagination issue or 404 page after Yoast – dropping of post category slug from the url?

Well, we can easily drop off the “categories” prefix from the category URLs or post with category URLs to make it more readable, presentable, and structured.

Let’s take an example to understand the working.

By default, if you have created categories in your WordPress website you will see the following URL structure.

Category Archive or Post Listings URL restructuring


The paginated page will appear as:


Now, suppose… you want to drop this “category” prefix from the above URLs and simply want to keep the URLs as:



To do this change, you simply need to use the Yoast Plugin – Remove the categories prefix? option.

It can be found inside the Search Appearance >> Taxonomies tab (Scroll down to the bottom).

Category Archive or Post Listings URL restructuring
To switch it on or remove the Categories prefix. Change the settings to “Remove” and click on save changes to save these configurations.

Post URL restructuring

By default, your article post URLs are as https://makemypost.com/{post_slug}/ or, https://makemypost.com/health-fitness/

And, if you want the URLs to have the category name or slug as a prefix. You have to do changes to the permalink structure of your WordPress website.

Click on Settings >>Permalinks

And, make sure… your settings reflect as the attached screenshot.

Post URL restructuring

i.e. Select the “Custom Structure” option and include the %category%/%postname%/ in the text field.

Save the changes.

This will make the post URL to work as:


Or, https://makemypost.com/web/top-5-useful-wordpress-plugins-for-your-website/

With the above changes, you will have your URLs on the website well structured to handle both categories and category posts. But making such changes might cause some 404 issues in the pagination. Specifically, if you have the entire posts using a separate slug-like “blog” or “resources”. Example:


To handle such cases you need to add the following piece of code in your themes functions.php file.

function remove_category_slug_url($query_string){ 
    if ($query_string['name'] == 'page' && isset($query_string['page'])) {
        list($delim, $page_index) = explode('/', $query_string['page']);
		if(empty($page_index)) $page_index = $query_string['page'];
        $query_string['paged'] = $page_index;
    return $query_string;
add_filter('request', 'remove_category_slug_url');

This code will ensure, you don’t have any 404 concerns in the paginated URLs of any category or index pages.

Reviews & Ratings Get your stoe online with Shopify in 60 minutes Shop Now