Archive monthly pages not found error
-
Archive widget working fine and shows the proper number of items per month but when I select any month I get a this page not found error. If I select http:website/cptslug I do get an Archive page with all the proper content but any archive monthly selection that should have an item (http:website/cptslug/2022/01/) comes back with page not found.
The page I need help with: [log in to see the link]
-
Hi @ricschug
Just to extra confirm, you’re sure the archive widget is configured to be including post types correct? Asking because I think by default it would only be going with the default
post
post type.Only other idea I had would be that the post type in question isn’t getting included in the date archive query, for which we should be able to amend with a
pre_get_post
hook call and update the query to include more.yes the archive widget points to the correct CPT. When the archive widget lists the posts it is correct and shows each month with the proper post count (configured for monthly and count) which makes me think it is finding them properly but when I select a specific month, with a post, it returns a page not found. Kinda like it cant find the page template but I thought it would simply find the archive.php at the top of the hierarchy and use that
I wonder if this amended snippet below, based on https://docs.pluginize.com/article/post-types-in-category-tag-archives/ would help here.
function my_cptui_add_post_types_to_archives( $query ) { // We do not want unintended consequences. if ( is_admin() || ! $query->is_main_query() ) { return; } // We are trying to show in a date based archive. if ( $query->is_date() && empty( $query->query_vars['suppress_filters'] ) ) { $cptui_post_types = cptui_get_post_type_slugs(); $query->set( 'post_type', array_merge( array( 'post' ), $cptui_post_types ) ); } } add_filter( 'pre_get_posts', 'my_cptui_add_post_types_to_archives' );
Michael, I tried the snippet with not effect. I also regenerated the permalinks and deleted and turned off caching still no change. I have 3 different CPTs and they all behave the same way. The Archive widget is correct with the proper month and count for each CPT but when I select a month is when I get the page not found. Seems like it just doesn’t know now to create the page.
Can you share your post types registration settings? Just visit
CPTUI > Tools
and you should see on the right a “Export Post Types settings” section. Just paste me the entire blob and I can work from that.{“memberposts”:{“name”:”memberposts”,”label”:”Member Posts”,”singular_label”:”Member Post”,”description”:”News for Members Only”,”public”:”true”,”publicly_queryable”:”true”,”show_ui”:”true”,”show_in_nav_menus”:”true”,”delete_with_user”:”false”,”show_in_rest”:”true”,”rest_base”:””,”rest_controller_class”:””,”rest_namespace”:””,”has_archive”:”true”,”has_archive_string”:””,”exclude_from_search”:”false”,”capability_type”:”post”,”hierarchical”:”false”,”can_export”:”false”,”rewrite”:”true”,”rewrite_slug”:””,”rewrite_withfront”:”true”,”query_var”:”true”,”query_var_slug”:””,”menu_position”:””,”show_in_menu”:”true”,”show_in_menu_string”:””,”menu_icon”:null,”register_meta_box_cb”:null,”supports”:[“title”,”editor”,”thumbnail”,”custom-fields”,”revisions”,”author”,”post-formats”],”taxonomies”:[],”labels”:{“menu_name”:”Member Posts”,”all_items”:”All Member Posts”,”add_new”:”Add new”,”add_new_item”:”Add new Member Post”,”edit_item”:”Edit Member Post”,”new_item”:”New Member Post”,”view_item”:”View Member Post”,”view_items”:”View Member Posts”,”search_items”:”Search Member Posts”,”not_found”:”No Member Posts found”,”not_found_in_trash”:”No Member Posts found in trash”,”parent”:”Parent Member Post:”,”featured_image”:”Featured image for this Member Post”,”set_featured_image”:”Set featured image for this Member Post”,”remove_featured_image”:”Remove featured image for this Member Post”,”use_featured_image”:”Use as featured image for this Member Post”,”archives”:”Member Post archives”,”insert_into_item”:”Insert into Member Post”,”uploaded_to_this_item”:”Upload to this Member Post”,”filter_items_list”:”Filter Member Posts list”,”items_list_navigation”:”Member Posts list navigation”,”items_list”:”Member Posts list”,”attributes”:”Member Posts attributes”,”name_admin_bar”:”Member Post”,”item_published”:”Member Post published”,”item_published_privately”:”Member Post published privately.”,”item_reverted_to_draft”:”Member Post reverted to draft.”,”item_scheduled”:”Member Post scheduled”,”item_updated”:”Member Post updated.”,”parent_item_colon”:”Parent Member Post:”},”custom_supports”:””,”enter_title_here”:””},”memdiscussions”:{“name”:”memdiscussions”,”label”:”Member Discussions”,”singular_label”:”Member Discussion”,”description”:”Type for Members to use for discussions”,”public”:”true”,”publicly_queryable”:”true”,”show_ui”:”true”,”show_in_nav_menus”:”true”,”delete_with_user”:”false”,”show_in_rest”:”true”,”rest_base”:””,”rest_controller_class”:””,”has_archive”:”true”,”has_archive_string”:””,”exclude_from_search”:”true”,”capability_type”:”post”,”hierarchical”:”true”,”rewrite”:”true”,”rewrite_slug”:””,”rewrite_withfront”:”true”,”query_var”:”true”,”query_var_slug”:””,”menu_position”:””,”show_in_menu”:”true”,”show_in_menu_string”:””,”menu_icon”:””,”supports”:[“title”,”editor”,”thumbnail”,”comments”,”revisions”,”author”,”post-formats”],”taxonomies”:[],”labels”:{“menu_name”:”Member Discussions”,”all_items”:”All Member Discussions”,”add_new”:”Add new”,”add_new_item”:”Add new Member Discussion”,”edit_item”:”Edit Member Discussion”,”new_item”:”New Member Discussion”,”view_item”:”View Member Discussion”,”view_items”:”View Member Discussions”,”search_items”:”Search Member Discussions”,”not_found”:”No Member Discussions found”,”not_found_in_trash”:”No Member Discussions found in trash”,”parent”:”Parent Member Discussion:”,”featured_image”:”Featured image for this Member Discussion”,”set_featured_image”:”Set featured image for this Member Discussion”,”remove_featured_image”:”Remove featured image for this Member Discussion”,”use_featured_image”:”Use as featured image for this Member Discussion”,”archives”:”Member Discussion archives”,”insert_into_item”:”Insert into Member Discussion”,”uploaded_to_this_item”:”Upload to this Member Discussion”,”filter_items_list”:”Filter Member Discussions list”,”items_list_navigation”:”Member Discussions list navigation”,”items_list”:”Member Discussions list”,”attributes”:”Member Discussions attributes”,”name_admin_bar”:”Member Discussion”,”item_published”:”Member Discussion published”,”item_published_privately”:”Member Discussion published privately.”,”item_reverted_to_draft”:”Member Discussion reverted to draft.”,”item_scheduled”:”Member Discussion scheduled”,”item_updated”:”Member Discussion updated.”,”parent_item_colon”:”Parent Member Discussion:”},”custom_supports”:””},”membuysell”:{“name”:”membuysell”,”label”:”Member Buy\/Sell”,”singular_label”:”Member Buy\/Sell”,”description”:””,”public”:”true”,”publicly_queryable”:”true”,”show_ui”:”true”,”show_in_nav_menus”:”true”,”delete_with_user”:”true”,”show_in_rest”:”true”,”rest_base”:””,”rest_controller_class”:””,”has_archive”:”true”,”has_archive_string”:””,”exclude_from_search”:”true”,”capability_type”:”post”,”hierarchical”:”false”,”rewrite”:”true”,”rewrite_slug”:””,”rewrite_withfront”:”true”,”query_var”:”true”,”query_var_slug”:””,”menu_position”:””,”show_in_menu”:”true”,”show_in_menu_string”:””,”menu_icon”:””,”supports”:[“title”,”editor”,”thumbnail”,”revisions”,”author”],”taxonomies”:[],”labels”:{“menu_name”:”Member Buy\/Sell”,”all_items”:”All Member Buy\/Sell”,”add_new”:”Add new”,”add_new_item”:”Add new Member Buy\/Sell”,”edit_item”:”Edit Member Buy\/Sell”,”new_item”:”New Member Buy\/Sell”,”view_item”:”View Member Buy\/Sell”,”view_items”:”View Member Buy\/Sell”,”search_items”:”Search Member Buy\/Sell”,”not_found”:”No Member Buy\/Sell found”,”not_found_in_trash”:”No Member Buy\/Sell found in trash”,”parent”:”Parent Member Buy\/Sell:”,”featured_image”:”Featured image for this Member Buy\/Sell”,”set_featured_image”:”Set featured image for this Member Buy\/Sell”,”remove_featured_image”:”Remove featured image for this Member Buy\/Sell”,”use_featured_image”:”Use as featured image for this Member Buy\/Sell”,”archives”:”Member Buy\/Sell Archives”,”insert_into_item”:”Insert into Member Buy\/Sell”,”uploaded_to_this_item”:”Upload to this Member Buy\/Sell”,”filter_items_list”:”Filter Member Buy\/Sell list”,”items_list_navigation”:”Member Buy\/Sell list navigation”,”items_list”:”Member Buy\/Sell list”,”attributes”:”Member Buy\/Sell attributes”,”name_admin_bar”:”Member Buy\/Sell”,”item_published”:”Member Buy\/Sell published”,”item_published_privately”:”Member Buy\/Sell published privately.”,”item_reverted_to_draft”:”Member Buy\/Sell reverted to draft.”,”item_scheduled”:”Member Buy\/Sell scheduled”,”item_updated”:”Member Buy\/Sell updated.”,”parent_item_colon”:”Parent Member Buy\/Sell:”},”custom_supports”:””},”memvolunteers”:{“name”:”memvolunteers”,”label”:”Member Volunteers”,”singular_label”:”Member Volunteer”,”description”:”Posts for voluteering work work crews”,”public”:”true”,”publicly_queryable”:”true”,”show_ui”:”true”,”show_in_nav_menus”:”true”,”delete_with_user”:”false”,”show_in_rest”:”true”,”rest_base”:””,”rest_controller_class”:””,”has_archive”:”true”,”has_archive_string”:””,”exclude_from_search”:”false”,”capability_type”:”post”,”hierarchical”:”false”,”rewrite”:”true”,”rewrite_slug”:””,”rewrite_withfront”:”true”,”query_var”:”true”,”query_var_slug”:””,”menu_position”:””,”show_in_menu”:”true”,”show_in_menu_string”:””,”menu_icon”:””,”supports”:[“title”,”editor”,”thumbnail”,”comments”,”author”],”taxonomies”:[],”labels”:{“menu_name”:”Member Volunteers”,”all_items”:”All Volunteers”,”add_new”:”Add new”,”add_new_item”:”Add new Work Detail”,”edit_item”:”Edit Volunteer”,”new_item”:”New Volunteer Needed”,”view_item”:”View Volunteer”,”view_items”:”View Volunteers”,”search_items”:”Search Volunteers Needed”,”not_found”:”No Volunteers found”,”not_found_in_trash”:”No Volunteers found in trash”,”parent”:”Parent Volunteer:”,”featured_image”:”Featured image for this Volunteer”,”set_featured_image”:”Set featured image for this Volunteer”,”remove_featured_image”:”Remove featured image for this Volunteer”,”use_featured_image”:”Use as featured image for this Volunteer”,”archives”:”Volunteer archives”,”insert_into_item”:”Insert into Volunteer”,”uploaded_to_this_item”:”Upload to this Volunteer”,”filter_items_list”:”Filter Volunteers list”,”items_list_navigation”:”Volunteers list navigation”,”items_list”:”Volunteers list”,”attributes”:”Volunteers attributes”,”name_admin_bar”:”Volunteer”,”item_published”:”Volunteer published”,”item_published_privately”:”Volunteer published privately.”,”item_reverted_to_draft”:”Volunteer reverted to draft.”,”item_scheduled”:”Volunteer scheduled”,”item_updated”:”Volunteer updated.”,”parent_item_colon”:”Parent Volunteer:”},”custom_supports”:””},”boddiscussions”:{“name”:”boddiscussions”,”label”:”BOD Discussions”,”singular_label”:”BOD Discussion”,”description”:”Discussions for only BOD folks”,”public”:”true”,”publicly_queryable”:”true”,”show_ui”:”true”,”show_in_nav_menus”:”true”,”delete_with_user”:”false”,”show_in_rest”:”true”,”rest_base”:””,”rest_controller_class”:””,”has_archive”:”true”,”has_archive_string”:”https:\/\/www.wcfw.org\/”,”exclude_from_search”:”false”,”capability_type”:”post”,”hierarchical”:”false”,”rewrite”:”true”,”rewrite_slug”:””,”rewrite_withfront”:”true”,”query_var”:”true”,”query_var_slug”:””,”menu_position”:””,”show_in_menu”:”true”,”show_in_menu_string”:””,”menu_icon”:””,”supports”:[“title”,”editor”,”thumbnail”,”comments”,”revisions”,”author”,”page-attributes”,”post-formats”],”taxonomies”:[],”labels”:{“menu_name”:”BOD Discussions”,”all_items”:”All BOD Discussions”,”add_new”:”Add new”,”add_new_item”:”Add new BOD Discussion”,”edit_item”:”Edit BOD Discussion”,”new_item”:”New BOD Discussion”,”view_item”:”View BOD Discussion”,”view_items”:”View BOD Discussions”,”search_items”:”Search BOD Discussions”,”not_found”:”No BOD Discussions found”,”not_found_in_trash”:”No BOD Discussions found in trash”,”parent”:”Parent BOD Discussion:”,”featured_image”:”Featured image for this BOD Discussion”,”set_featured_image”:”Set featured image for this BOD Discussion”,”remove_featured_image”:”Remove featured image for this BOD Discussion”,”use_featured_image”:”Use as featured image for this BOD Discussion”,”archives”:”BOD Discussion archives”,”insert_into_item”:”Insert into BOD Discussion”,”uploaded_to_this_item”:”Upload to this BOD Discussion”,”filter_items_list”:”Filter BOD Discussions list”,”items_list_navigation”:”BOD Discussions list navigation”,”items_list”:”BOD Discussions list”,”attributes”:”BOD Discussions attributes”,”name_admin_bar”:”BOD Discussion”,”item_published”:”BOD Discussion published”,”item_published_privately”:”BOD Discussion published privately.”,”item_reverted_to_draft”:”BOD Discussion reverted to draft.”,”item_scheduled”:”BOD Discussion scheduled”,”item_updated”:”BOD Discussion updated.”,”parent_item_colon”:”Parent BOD Discussion:”},”custom_supports”:””}}
So we have 5 post types, and I published a post to each of them just now. I have the “Archives” widget in my footer area and it’s only showing me 1 post, from October 2022. So at least by post types registered and a post published, they are not showing up in the widget at all for me.
Are you sure your site isn’t doing some filtering of arguments for the widget? and not perhaps just the same amount of posts are in the post type as there are in the posts actually used in the widget count?
We are not doing any filtering. All our Archive widgets (month/counts) are correct for each CPT. And when I go to http:<site>/cptslug I get a page titled Archive and it lists all the proper items. Its only when I select a month/count from the archive widget that I get the page not found (http<site>/cptslug/2022/10 as an example)
Yes, correct. I’m still clear on the overall issue, but I’m not yet sure how to recreate the same locally because I can’t get the widget to show/include custom post types thus far, which has me wondering what’s maybe going on on your site. Default values are giving me results with just the
post
post type. That’s what’s confusing me.
- The topic ‘Archive monthly pages not found error’ is closed to new replies.