Skip Navigation

[Resolved] Getting 404 Page Not Found for Custom Post Type Pagination

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a custom post type set up and I'm trying to access the post archives. The first page of results is fine, but any additional pages show 404 errors.

Solution: Check the post type options and be sure "Pages" is checked. This allows pagination in the URL rewrite rules.

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Alok Sharma 5 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1162132

I have created a Custom Post Type and accordingly create an archive template in Elementor Pro for the same.

However, when I navigate to the CPT on the front-end, I encounter 404 Page Not Found from 2nd page onwards.

I have tried everything I could do to debug the problem including reviewing solutions posted by other people on various sites but it all tuned out to be in vain.

#1162480

Hi, I don't see anything obvious that should be causing problems. Could you turn on server logs to see if any errors are generated on the server? If you're not familiar with server logs, I can show you how to activate them temporarily. Go in your wp-config.php file and look for

define('WP_DEBUG', false);

Change it to:

define('WP_DEBUG', true);

Then add these lines, just before it says 'stop editing here':

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

Then reload page 2 of the archive. If any errors are thrown, this will create an error_log.txt file in your site's root directory. Please send me its contents. Once that is done, you can revert the changes you made to wp-config.php.

If no error_log.txt file is created, please temporarily deactivate all plugins except Types, Elementor, and Elementor Pro. Then activate the default Twenty Nineteen theme and test again. If the problem is resolved, reactivate your theme and other plugins one by one until the problem returns.

Let me know the results of these tests and we can go from there.

#1162662

Hi Christian,

Thank you for your reply.

I followed your instructions and this is what I encountered:

Notice: Trying to get property of non-object in /home/*****/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/widgets/post-content.php on line 114

Notice: Trying to get property of non-object in /home/*****/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/widgets/post-content.php on line 121

Notice: Trying to get property of non-object in /home/*****/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/widgets/post-content.php on line 125

Notice: Trying to get property of non-object in /home/*****/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/widgets/post-content.php on line 128

Notice: Trying to get property of non-object in /home/*****/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/widgets/post-content.php on line 131

Notice: Trying to get property of non-object in /home/*****/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/widgets/post-content.php on line 153

Notice: Trying to get property of non-object in /home/*****/public_html/wp-includes/post-template.php on line 298

I have sent this information to Elementor and awaiting their reply.

#1162916

Okay thanks for running those tests. If you approve, I will log into your site and try to create a site clone using the Duplicator plugin. Then I can install the site on my local environment to reproduce and isolate the problem. If that's okay with you, I will get started.

#1162943

Hi Christian,

You may please proceed with the same.

#1163133
Screen Shot 2018-12-10 at 3.45.51 PM.png

I wasn't able to replicate the 404 error on my own local site, so I returned to your site and did some additional troubleshooting. I resaved the site permalinks, and now I'm seeing the archive page appear without a 404:
https://shutterbugs.co.in/career-in-photograph/
Can you take a look and let me know if this is has not resolved the problem?

#1163473

Hi Christian,

The problem is not with the 1st page of the archive.

It begins from the 2nd page and onwards.

Yesterday, I disabled all the plugins except Toolset and switched the theme to 2019. At that time, the theme wasn't throwing any PHP errors. Instead, it was showing 404 Page Not Found message without any PHP errors.

#1163908
Screen Shot 2018-12-11 at 11.20.20 AM.png

Okay I think I have discovered the problem. In the Career in Photography post type editor, the option "Pages" was unchecked. I have checked that option, and now pagination appears to be working as expected in the archive. Can you confirm?

#1163933

Hi Christian,

Thanks a million for fixing this out.

However, I am still confused with the "Pages" option. As I read in the documentation, it states "Pages – is the custom post type a dynamic (post) or static (page) piece of content."

If you could please help me out with this.

Thanks

#1163997

It's confusing, I must agree with you. Basically this option indicates whether or not you want to include pagination in the rewrite rules for this post type. A static post type (like native WordPress Pages) does not require pagination in the URL rewrite rules. This argument is represented in the WordPress documentation here under Parameters > Arguments > rewrite > pages: https://codex.wordpress.org/Function_Reference/register_post_type#Arguments

#1164494

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.