admin管理员组

文章数量:1287629

I have a website that, using ACF Pro, I have created several Custom Post Types (CPTs) for. All using ACF Pro. Of them, 6 of the CPTs are showing fine with the archive and single templates. They are: Blogs, Case Studies, Datasheets, Events, In The News, and Press Releases.

The remaining one (Videos) is fine viewing the archive - both posts show on it, but I'm getting 404 errors when trying to view the individual posts.

This is happening in both the DEV environment on Kinsta and in my local environment on my workstation.

I have tried the following in my local and my DEV Server environments:

  • Using a default theme ("Twenty Twenty-Two")
  • Removing all the custom fields from these 2 post types leaving one to test;
  • Deleting and rebuilding the CPTs that are broken;
  • Flushing the permalinks (saving permalinks);
  • Clearing my cache;
  • Different Browsers (Chrome and Edge)
  • Deleting and rebuilding the posts with different slugs;
  • Ensured there are no pages (or other posts) with the same slugs (at least not that I can see in the admin);
  • Disabling all plugins except ACF;
  • also removed the categories that contained similar slugs, then re-added with different slugs I'm not using any customized rewrite rules. Whatever, Wordpress has and whatever is on the Kinsta server(s) is what's in use.

None of these has corrected the issue. Here is a link to the archive for the Videos. As you can see, it works fine, but clicking on either of the individual posts is when the 404 appears: /resources/videos/

I'm very confused as to why this post type is the issue and all the other CPTs are fine.

Here's the exported JSON of both the blogs CPT (working) and the Videos CPT (breaking):

{
        "key": "post_type_649b3505216bd",
        "title": "Blogs",
        "menu_order": 0,
        "active": true,
        "post_type": "blogs",
        "advanced_configuration": true,
        "import_source": "",
        "import_date": "",
        "labels": {
            "name": "Blogs",
            "singular_name": "Blog",
            "menu_name": "Blogs",
            "all_items": "All Blogs",
            "edit_item": "Edit Blog",
            "view_item": "View Blog",
            "view_items": "View Blogs",
            "add_new_item": "Add New Blog",
            "add_new": "Add New Blog",
            "new_item": "New Blog",
            "parent_item_colon": "Parent Blog:",
            "search_items": "Search Blogs",
            "not_found": "No blogs found",
            "not_found_in_trash": "No blogs found in Trash",
            "archives": "Blog Archives",
            "attributes": "Blog Attributes",
            "featured_image": "",
            "set_featured_image": "",
            "remove_featured_image": "",
            "use_featured_image": "",
            "insert_into_item": "Insert into blog",
            "uploaded_to_this_item": "Uploaded to this blog",
            "filter_items_list": "Filter blogs list",
            "filter_by_date": "Filter blogs by date",
            "items_list_navigation": "Blogs list navigation",
            "items_list": "Blogs list",
            "item_published": "Blog published.",
            "item_published_privately": "Blog published privately.",
            "item_reverted_to_draft": "Blog reverted to draft.",
            "item_scheduled": "Blog scheduled.",
            "item_updated": "Blog updated.",
            "item_link": "Blog Link",
            "item_link_description": "A link to a blog."
        },
        "description": "For content marketing on new information about products and services, reviews, opinions, and reputation management",
        "public": true,
        "hierarchical": true,
        "exclude_from_search": false,
        "publicly_queryable": true,
        "show_ui": true,
        "show_in_menu": true,
        "admin_menu_parent": "",
        "show_in_admin_bar": true,
        "show_in_nav_menus": true,
        "show_in_rest": true,
        "rest_base": "",
        "rest_namespace": "wp\/v2",
        "rest_controller_class": "WP_REST_Posts_Controller",
        "menu_position": "",
        "menu_icon": "dashicons-welcome-write-blog",
        "rename_capabilities": false,
        "singular_capability_name": "post",
        "plural_capability_name": "posts",
        "supports": [
            "title",
            "custom-fields"
        ],
        "taxonomies": [
            "post_tag",
            "category"
        ],
        "has_archive": true,
        "has_archive_slug": "resources\/blogs",
        "rewrite": {
            "permalink_rewrite": "custom_permalink",
            "slug": "resources\/blogs",
            "with_front": "1",
            "feeds": "1",
            "pages": "1"
        },
        "query_var": "post_type_key",
        "query_var_name": "",
        "can_export": true,
        "delete_with_user": false,
        "register_meta_box_cb": "",
        "enter_title_here": ""
    },
    {
        "key": "post_type_649b3f54635ce",
        "title": "Videos",
        "menu_order": 0,
        "active": true,
        "post_type": "video",
        "advanced_configuration": true,
        "import_source": "",
        "import_date": "",
        "labels": {
            "name": "Videos",
            "singular_name": "Video",
            "menu_name": "Videos",
            "all_items": "All Videos",
            "edit_item": "Edit Video",
            "view_item": "View Video",
            "view_items": "View Videos",
            "add_new_item": "Add New Video",
            "add_new": "",
            "new_item": "New Video",
            "parent_item_colon": "Parent Video:",
            "search_items": "Search Videos",
            "not_found": "No videos found",
            "not_found_in_trash": "No videos found in Trash",
            "archives": "Video Archives",
            "attributes": "Video Attributes",
            "featured_image": "",
            "set_featured_image": "",
            "remove_featured_image": "",
            "use_featured_image": "",
            "insert_into_item": "Insert into video",
            "uploaded_to_this_item": "Uploaded to this video",
            "filter_items_list": "Filter videos list",
            "filter_by_date": "Filter videos by date",
            "items_list_navigation": "Videos list navigation",
            "items_list": "Videos list",
            "item_published": "Video published.",
            "item_published_privately": "Video published privately.",
            "item_reverted_to_draft": "Video reverted to draft.",
            "item_scheduled": "Video scheduled.",
            "item_updated": "Video updated.",
            "item_link": "Video Link",
            "item_link_description": "A link to a video."
        },
        "description": "Videos produced by Patra about Patra services",
        "public": true,
        "hierarchical": true,
        "exclude_from_search": false,
        "publicly_queryable": true,
        "show_ui": true,
        "show_in_menu": true,
        "admin_menu_parent": "",
        "show_in_admin_bar": true,
        "show_in_nav_menus": true,
        "show_in_rest": true,
        "rest_base": "",
        "rest_namespace": "wp\/v2",
        "rest_controller_class": "WP_REST_Posts_Controller",
        "menu_position": "",
        "menu_icon": "dashicons-video-alt",
        "rename_capabilities": false,
        "singular_capability_name": "post",
        "plural_capability_name": "posts",
        "supports": [
            "title",
            "custom-fields"
        ],
        "taxonomies": [
            "post_tag",
            "category"
        ],
        "has_archive": true,
        "has_archive    _slug": "resources\/videos",
        "rewrite": {
            "permalink_rewrite": "custom_permalink",
            "slug": "resources\/videos",
            "with_front": "1",
            "feeds": "1",
            "pages": "1"
        },
        "query_var": "post_type_key",
        "query_var_name": "",
        "can_export": true,
        "delete_with_user": false,
        "register_meta_box_cb": "",
        "enter_title_here": ""
    },                      

I have a website that, using ACF Pro, I have created several Custom Post Types (CPTs) for. All using ACF Pro. Of them, 6 of the CPTs are showing fine with the archive and single templates. They are: Blogs, Case Studies, Datasheets, Events, In The News, and Press Releases.

The remaining one (Videos) is fine viewing the archive - both posts show on it, but I'm getting 404 errors when trying to view the individual posts.

This is happening in both the DEV environment on Kinsta and in my local environment on my workstation.

I have tried the following in my local and my DEV Server environments:

  • Using a default theme ("Twenty Twenty-Two")
  • Removing all the custom fields from these 2 post types leaving one to test;
  • Deleting and rebuilding the CPTs that are broken;
  • Flushing the permalinks (saving permalinks);
  • Clearing my cache;
  • Different Browsers (Chrome and Edge)
  • Deleting and rebuilding the posts with different slugs;
  • Ensured there are no pages (or other posts) with the same slugs (at least not that I can see in the admin);
  • Disabling all plugins except ACF;
  • also removed the categories that contained similar slugs, then re-added with different slugs I'm not using any customized rewrite rules. Whatever, Wordpress has and whatever is on the Kinsta server(s) is what's in use.

None of these has corrected the issue. Here is a link to the archive for the Videos. As you can see, it works fine, but clicking on either of the individual posts is when the 404 appears: https://stg-patraprime-patradev.kinsta.cloud/resources/videos/

I'm very confused as to why this post type is the issue and all the other CPTs are fine.

Here's the exported JSON of both the blogs CPT (working) and the Videos CPT (breaking):

{
        "key": "post_type_649b3505216bd",
        "title": "Blogs",
        "menu_order": 0,
        "active": true,
        "post_type": "blogs",
        "advanced_configuration": true,
        "import_source": "",
        "import_date": "",
        "labels": {
            "name": "Blogs",
            "singular_name": "Blog",
            "menu_name": "Blogs",
            "all_items": "All Blogs",
            "edit_item": "Edit Blog",
            "view_item": "View Blog",
            "view_items": "View Blogs",
            "add_new_item": "Add New Blog",
            "add_new": "Add New Blog",
            "new_item": "New Blog",
            "parent_item_colon": "Parent Blog:",
            "search_items": "Search Blogs",
            "not_found": "No blogs found",
            "not_found_in_trash": "No blogs found in Trash",
            "archives": "Blog Archives",
            "attributes": "Blog Attributes",
            "featured_image": "",
            "set_featured_image": "",
            "remove_featured_image": "",
            "use_featured_image": "",
            "insert_into_item": "Insert into blog",
            "uploaded_to_this_item": "Uploaded to this blog",
            "filter_items_list": "Filter blogs list",
            "filter_by_date": "Filter blogs by date",
            "items_list_navigation": "Blogs list navigation",
            "items_list": "Blogs list",
            "item_published": "Blog published.",
            "item_published_privately": "Blog published privately.",
            "item_reverted_to_draft": "Blog reverted to draft.",
            "item_scheduled": "Blog scheduled.",
            "item_updated": "Blog updated.",
            "item_link": "Blog Link",
            "item_link_description": "A link to a blog."
        },
        "description": "For content marketing on new information about products and services, reviews, opinions, and reputation management",
        "public": true,
        "hierarchical": true,
        "exclude_from_search": false,
        "publicly_queryable": true,
        "show_ui": true,
        "show_in_menu": true,
        "admin_menu_parent": "",
        "show_in_admin_bar": true,
        "show_in_nav_menus": true,
        "show_in_rest": true,
        "rest_base": "",
        "rest_namespace": "wp\/v2",
        "rest_controller_class": "WP_REST_Posts_Controller",
        "menu_position": "",
        "menu_icon": "dashicons-welcome-write-blog",
        "rename_capabilities": false,
        "singular_capability_name": "post",
        "plural_capability_name": "posts",
        "supports": [
            "title",
            "custom-fields"
        ],
        "taxonomies": [
            "post_tag",
            "category"
        ],
        "has_archive": true,
        "has_archive_slug": "resources\/blogs",
        "rewrite": {
            "permalink_rewrite": "custom_permalink",
            "slug": "resources\/blogs",
            "with_front": "1",
            "feeds": "1",
            "pages": "1"
        },
        "query_var": "post_type_key",
        "query_var_name": "",
        "can_export": true,
        "delete_with_user": false,
        "register_meta_box_cb": "",
        "enter_title_here": ""
    },
    {
        "key": "post_type_649b3f54635ce",
        "title": "Videos",
        "menu_order": 0,
        "active": true,
        "post_type": "video",
        "advanced_configuration": true,
        "import_source": "",
        "import_date": "",
        "labels": {
            "name": "Videos",
            "singular_name": "Video",
            "menu_name": "Videos",
            "all_items": "All Videos",
            "edit_item": "Edit Video",
            "view_item": "View Video",
            "view_items": "View Videos",
            "add_new_item": "Add New Video",
            "add_new": "",
            "new_item": "New Video",
            "parent_item_colon": "Parent Video:",
            "search_items": "Search Videos",
            "not_found": "No videos found",
            "not_found_in_trash": "No videos found in Trash",
            "archives": "Video Archives",
            "attributes": "Video Attributes",
            "featured_image": "",
            "set_featured_image": "",
            "remove_featured_image": "",
            "use_featured_image": "",
            "insert_into_item": "Insert into video",
            "uploaded_to_this_item": "Uploaded to this video",
            "filter_items_list": "Filter videos list",
            "filter_by_date": "Filter videos by date",
            "items_list_navigation": "Videos list navigation",
            "items_list": "Videos list",
            "item_published": "Video published.",
            "item_published_privately": "Video published privately.",
            "item_reverted_to_draft": "Video reverted to draft.",
            "item_scheduled": "Video scheduled.",
            "item_updated": "Video updated.",
            "item_link": "Video Link",
            "item_link_description": "A link to a video."
        },
        "description": "Videos produced by Patra about Patra services",
        "public": true,
        "hierarchical": true,
        "exclude_from_search": false,
        "publicly_queryable": true,
        "show_ui": true,
        "show_in_menu": true,
        "admin_menu_parent": "",
        "show_in_admin_bar": true,
        "show_in_nav_menus": true,
        "show_in_rest": true,
        "rest_base": "",
        "rest_namespace": "wp\/v2",
        "rest_controller_class": "WP_REST_Posts_Controller",
        "menu_position": "",
        "menu_icon": "dashicons-video-alt",
        "rename_capabilities": false,
        "singular_capability_name": "post",
        "plural_capability_name": "posts",
        "supports": [
            "title",
            "custom-fields"
        ],
        "taxonomies": [
            "post_tag",
            "category"
        ],
        "has_archive": true,
        "has_archive    _slug": "resources\/videos",
        "rewrite": {
            "permalink_rewrite": "custom_permalink",
            "slug": "resources\/videos",
            "with_front": "1",
            "feeds": "1",
            "pages": "1"
        },
        "query_var": "post_type_key",
        "query_var_name": "",
        "can_export": true,
        "delete_with_user": false,
        "register_meta_box_cb": "",
        "enter_title_here": ""
    },                      
Share Improve this question asked Oct 19, 2023 at 8:41 Mitch SMitch S 275 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 2

The issue you're facing might be due to a conflict with the slug of your custom post type and a page, post, or another custom post type.

From the JSON you've provided, it seems like the slug for your Videos CPT is resources/videos. If there's a page or post with the slug videos or resources, it might be causing the issue.

Here are a few things you can try:

  1. Check if there's a page, post, or another custom post type with the slug videos or resources. If there is, try changing the slug of that page, post, or custom post type.

  2. Try changing the slug of your Videos CPT to something unique that doesn't conflict with any other slugs on your site. You can do this by changing the slug value in the rewrite array of your Videos CPT. For example:

     "rewrite": {
         "permalink_rewrite": "custom_permalink",
         "slug": "unique-videos-slug",
         "with_front": "1",
         "feeds": "1",
         "pages": "1"
     },
    

Thank you to alexandrucarjan for the path to getting a temporary workaround on this issue.

The answer was in the permalink and the URL rewrite. But, it was centered around nesting the video custom post type (single page) under the "Resources" slug, as I had with all of the other custom post types. Apparently, this post type was choking on it. But, only with the single pages, the archive still comes up fine.

I still have no answer as to why. I checked the database and ran a query for all the post names that contained "video" .. and only the 2 I created came up. Very strange.

Anyhow ..

So .. instead of a single post for this custom post type URL being:

https://DOMAN/resources/videos/video-operational-excellence/

It's now:

https://DOMAN/resource/videos/video-operational-excellence/

Resources no longer contains the plural ("s"). But, only for this post type. For all the other post types, it's "resourceS". Not desirable, but, it's definitely a work-around for now.

WordPress is like a box of chocolates, you never know what you're gonna get!

本文标签: custom post typesSingle Posts returning 404 Errorsflushing permalinks does not correct