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.
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.
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.
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.
Hi Christian,
You may please proceed with the same.
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?
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.
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?
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
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
My issue is resolved now. Thank you!