404 with tag posts
-
I have imported a few custom post types from Drupal to WP and they all work fine except my downloads. The posts are visible on the tags pages and listed, in the dashboard as well as being editable but the URLs to view the posts are not working.
Got any thoughts?
name: downloads label: Downloads singular_label: Download description: Use downloads for displaying downloadable content, such as Free 3D models or, & Free wallpaper pages. 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: 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: "" custom_supports: ""
-
I would read over https://docs.pluginize.com/article/17-post-types-in-category-tag-archives as it explains in greater detail what I suspect you’re seeing right now, which is that the category/tag term archives aren’t including your post types with their queries. A detail that is true with out of box WordPress. Thus the post types need to be told to be included.
Yeah, I have this in my functions.php but it is not making any difference.
/** * Adding all CPTUI post types to the archives. */ function my_cptui_add_post_types_to_archives( $query ) { // We do not want unintended consequences. if ( is_admin() || ! $query->is_main_query() ) { return; } if ( is_category() || is_tag() && 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' );
Just in case, do you have any posts from the post type published, with any of the tags being tested with their archive?
404 link https://localhost/infinitee-designs.com/downloads/1970-mach-1-ford-mustang/ From dashboard: List of Content type "Downloads" Posts are editable and can be saved but link to view come up 404. From front end: List is propagated on tag pages with title, image and short description but all links to post are 404. https://localhost/infinitee-designs.com/free-stuff/3d-models-for-maya-3d-studio-max/ https://localhost/infinitee-designs.com/downloads/1970-mach-1-ford-mustang/ Screenshots: https://www.infinitee-designs.com/sites/infinitee-designs.com/files/404-local.jpg https://www.infinitee-designs.com/sites/infinitee-designs.com/files/404-local-2.jpg
Can you visit the Tools > Post types tab and Tools > Taxonomies tab and paste me the contents on the right hand side of each ? I want to see what all you have registered here. I think you using “tag” initially had me thinking you were dealing with the out-of-box “post_tag” taxonomy, but based on the latest reply, I’m not so sure. So I’d like to review used settings.
{"blog":{"name":"blog","label":"Blog entries","singular_label":"Blog entry","labels":{"name":"Blog entries","singular_name":"Blog entry","add_new":"Add New","add_new_item":"Add New Blog entry","edit_item":"Edit Blog entry","new_item":"New Blog entry","view_item":"View Blog entry","search_items":"Search Blog entry","not_found":"No Blog entry found","not_found_in_trash":"No Blog entry found in Trash","parent_item_colon":"Parent Blog entry","all_items":"Blog entries"},"description":"Use for multi-user blogs. Every user gets a personal blog.","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","author","custom-fields"],"taxonomies":[],"custom_supports":""},"downloads":{"name":"downloads","label":"Downloads","singular_label":"Download","description":"Use downloads for displaying downloadable content, such as Free 3D models or, & Free wallpaper pages.","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":"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","author"],"taxonomies":["genre","free_stuff"],"labels":{"all_items":"Downloads","add_new":"Add New","add_new_item":"Add New Download","edit_item":"Edit Download","new_item":"New Download","view_item":"View Download","search_items":"Search Download","not_found":"No Download found","not_found_in_trash":"No Download found in Trash","menu_name":"","view_items":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":""},"featured_artist_gall":{"name":"featured_artist_gall","label":"Featured Artist Galleries","singular_label":"Featured Artist Gallery","labels":{"name":"Featured Artist Galleries","singular_name":"Featured Artist Gallery","add_new":"Add New","add_new_item":"Add New Featured Artist Gallery","edit_item":"Edit Featured Artist Gallery","new_item":"New Featured Artist Gallery","view_item":"View Featured Artist Gallery","search_items":"Search Featured Artist Gallery","not_found":"No Featured Artist Gallery found","not_found_in_trash":"No Featured Artist Gallery found in Trash","parent_item_colon":"Parent Featured Artist Gallery","all_items":"Featured Artist Galleries"},"description":"Featured artists gallery of artworks.","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","author","custom-fields"],"taxonomies":[],"custom_supports":""},"node_gallery_gallery":{"name":"node_gallery_gallery","label":"Galleries","singular_label":"Gallery","description":"The art galleries of artist Ralph Hawke Manis.","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":"gallery","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","author"],"taxonomies":[],"labels":{"all_items":"Galleries","add_new":"Add New","add_new_item":"Add New Gallery","edit_item":"Edit Gallery","new_item":"New Gallery","view_item":"View Gallery","search_items":"Search Gallery","not_found":"No Gallery found","not_found_in_trash":"No Gallery found in Trash","menu_name":"","view_items":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":""},"node_gallery_item":{"name":"node_gallery_item","label":"Gallery Items","singular_label":"Gallery Item","description":"A gallery node item.","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":"artwork","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","author"],"taxonomies":["post_tag","genre"],"labels":{"all_items":"Gallery Items","add_new":"Add New","add_new_item":"Add New Gallery Item","edit_item":"Edit Gallery Item","new_item":"New Gallery Item","view_item":"View Gallery Item","search_items":"Search Gallery Item","not_found":"No Gallery Item found","not_found_in_trash":"No Gallery Item found in Trash","menu_name":"","view_items":"","parent_item_colon":"","featured_image":"","set_featured_image":"","remove_featured_image":"","use_featured_image":"","archives":"","insert_into_item":"","uploaded_to_this_item":"","filter_items_list":"","items_list_navigation":"","items_list":"","attributes":"","name_admin_bar":"","item_published":"","item_published_privately":"","item_reverted_to_draft":"","item_scheduled":"","item_updated":""},"custom_supports":""},"window_decals_sticke":{"name":"window_decals_sticke","label":"Window Decals Stickers Product Displays","singular_label":"Window Decals Stickers Product Display","labels":{"name":"Window Decals Stickers Product Displays","singular_name":"Window Decals Stickers Product Display","add_new":"Add New","add_new_item":"Add New Window Decals Stickers Product Display","edit_item":"Edit Window Decals Stickers Product Display","new_item":"New Window Decals Stickers Product Display","view_item":"View Window Decals Stickers Product Display","search_items":"Search Window Decals Stickers Product Display","not_found":"No Window Decals Stickers Product Display found","not_found_in_trash":"No Window Decals Stickers Product Display found in Trash","parent_item_colon":"Parent Window Decals Stickers Product Display","all_items":"Window Decals Stickers Product Displays"},"description":"<em>Window Decals Stickers Product Display<\/em> A node content type to be used in conjunction with Window Decals Stickers Products which contain product variations.","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","author","custom-fields"],"taxonomies":[],"custom_supports":""}} {"genre":{"name":"genre","label":"Genres","singular_label":"Genre","labels":{"name":"Genres","singular_name":"Genre","search_items":"Search Genres","popular_items":"Popular Genres","all_items":"All Genres","parent_item":"Parent Genre","parent_item_colon":"Parent Genre:","edit_item":"Edit Genre","view_item":"View Genre","update_item":"Update Genre","add_new_item":"Add New Genre","new_item_name":"New Genre Name","separate_items_with_commas":"Separate Genres with commas","add_or_remove_items":"Add or remove Genres","choose_from_most_used":"Choose from the most used Genres","not_found":"No Genres found.","no_terms":"No Genres","items_list_navigation":"Genres list navigation","items_list":"Genres list","menu_name":"Genres","name_admin_bar":"Genres"},"description":"Genre of art that this work applies to..","public":"true","publicly_queryable":"true","hierarchical":"true","show_ui":"true","show_in_menu":"true","show_in_nav_menus":"true","query_var":"true","query_var_slug":"","rewrite":"true","rewrite_slug":"","rewrite_withfront":"true","rewrite_hierarchical":"true","show_admin_column":"true","show_in_rest":"true","show_in_quick_edit":"true","rest_base":"","rest_controller_class":"","meta_box_cb":"","default_term":"","object_types":["downloads","node_gallery_item"]},"free_stuff":{"name":"free_stuff","label":"Free Stuff","singular_label":"Free Stuff","description":"Free stuff downloads","public":"true","publicly_queryable":"true","hierarchical":"true","show_ui":"true","show_in_menu":"true","show_in_nav_menus":"true","query_var":"true","query_var_slug":"","rewrite":"true","rewrite_slug":"free-stuff","rewrite_withfront":"1","rewrite_hierarchical":"1","show_admin_column":"true","show_in_rest":"true","show_tagcloud":"false","show_in_quick_edit":"true","rest_base":"","rest_controller_class":"","labels":{"menu_name":"Free Stuff","all_items":"All Free Stuff","edit_item":"Edit Free Stuff","view_item":"View Free Stuff","update_item":"Update Free Stuff","add_new_item":"Add New Free Stuff","new_item_name":"New Free Stuff Name","parent_item":"Parent Free Stuff","parent_item_colon":"Parent Free Stuff:","search_items":"Search Free Stuff","popular_items":"Popular Free Stuff","separate_items_with_commas":"Separate Free Stuffs with commas","add_or_remove_items":"Add or remove Free Stuff","choose_from_most_used":"Choose from the most used Free Stuff","not_found":"No Free Stuffs found.","no_terms":"No Free Stuff","items_list_navigation":"Free Stuffs list navigation","items_list":"Free Stuffs list","back_to_items":""},"meta_box_cb":"","default_term":"","object_types":["downloads"]}}
- This reply was modified 2 years, 9 months ago by Infinitee.
Definitely seeing the content relationships better and it is how I was thinking. Much less
post_tag
archive, which negates my original reply.So we have a “Downloads” post type, and it has both “Genre” and “Free Stuff” taxonomies associated.
I’m looking at https://www.infinitee-designs.com/sites/infinitee-designs.com/files/404-local.jpg and that looks like it’s the archive for the “3d-models-for-maya-3d-studio-max” term, and is showing the 1970 Mach 1 Ford Mustang as part of its loop output.
I’m also looking at https://www.infinitee-designs.com/sites/infinitee-designs.com/files/404-local-2.jpg which looks like it showing the post as published, with the “3d-models-for-maya-3d-studio-max” term associated with it.
So, it’s when viewing that “1970 Mach 1 Ford Mustang” post directly, at it’s permalink that it’s 404ing?
Just in case, since you mention importing, have you cleared your permalinks recently. You can do that by visiting the Permalinks page and then just clicking the save button, without editing anything.
Once that’s done, re-try visiting the 404ing permalink and see if anything is different.
Beyond that, nothing is standing out for me thus far.
So, it’s when viewing that “1970 Mach 1 Ford Mustang” post directly, at it’s permalink that it’s 404ing?
Yes, it’s when trying to view the “1970 Mach 1 Ford Mustang” and all links to all Download > Free Stuff items are 404. I have resaved the permalinks a dozen times over the past 3 days without any change.
- This reply was modified 2 years, 9 months ago by Infinitee.
Any customizations like
pre_get_post
hook usage that could be throwing the query astray?None. This is all I have in my function.php…
/** * Enable reviews for all NEW WC Products. */ add_filter('get_default_comment_status', function($status, $post_type) { if($post_type === 'product') { return 'open'; } return $status; }, 10, 2); /** * Enable reviews for all WC Products. */ add_action('admin_init', function() { $updated = 0; $query = new \WP_Query([ 'post_type' => 'product', 'posts_per_page' => -1, 'comment_status' => 'closed', ]); if($query->have_posts()) { while($query->have_posts()) { $query->the_post(); if(wp_update_post([ 'ID' => get_the_ID(), 'comment_status' => 'open', ])) { $updated++; } } wp_reset_postdata(); } add_action('admin_notices', function() use ($updated) { printf( '<div class="notice notice-info is-dismissible"><p>Enabled reviews for %d products.</p></div>', (int)$updated ); }); }); /** * Adding all CPTUI post types to the archives. */ function my_cptui_add_post_types_to_archives( $query ) { // We do not want unintended consequences. if ( is_admin() || ! $query->is_main_query() ) { return; } if ( is_category() || is_tag() && 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' ); /** * Remove title - Archive: from archive posts. */ add_filter( 'get_the_archive_title', 'wpsite_archive_title_remove_prefix' ); function wpsite_archive_title_remove_prefix( $title ) { if ( is_post_type_archive() ) { $title = post_type_archive_title( '', false ); } return $title; }
You should be able to get rid of this part to avoid confusion and code clutter:
/** * Adding all CPTUI post types to the archives. */ function my_cptui_add_post_types_to_archives( $query ) { // We do not want unintended consequences. if ( is_admin() || ! $query->is_main_query() ) { return; } if ( is_category() || is_tag() && 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' );
Beyond that, I’m not sure what all may be going on, without being able to access myself, which I think is a no-go since I believe it’s all been local development on your computer.
Hey @infinitee did you ever get this figured out?
Yes, but it was very complex and a while ago so I don’t remember exactly how I fixed it.
No worries on the remembering part, I’m just glad you got it working.
Let us know if you need anything else.
- The topic ‘404 with tag posts’ is closed to new replies.