0

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": ""
    },                      

3 Answers 3

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"
     },
    
2
  • Well, that confuses me even more. The archive itself - "/resources/videos/", load just fine. It's the single posts - "/resources/videos/video-operational-excellence/", that are breaking. If the slug conflict is actually the culprit, would it not affect the archive as well? Additionally, I just noticed this is also happening with the webinars .. same, exact thing. So, I tried created a new CPT titled "testposttype". For that one, the archive was fine. The single post, also returned a 404 error. I did all the same troubleshooting I bulleted above .. and got the same result.
    – Mitch S
    Commented Oct 19, 2023 at 14:56
  • Your solution led me to the - temporary - answer. Still do not know "why" this was an issue. But, I have a workaround in place.
    – Mitch S
    Commented Oct 19, 2023 at 20:44
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.

0

WordPress is like a box of chocolates, you never know what you're gonna get! 😅 Here's a few thoughts:

  1. .htaccess Woes: Checked your .htaccess lately? Might be some funky stuff going on there. Resetting it to WordPress's default might be a good place to start.

  2. Rule Order Matters: WP checks those rewrite rules in a specific order. It's possible another rule (maybe from a plugin) is causing some interference. I'd recommend using the "Rewrite Rules Inspector" plugin. It’s super handy for this kind of stuff: Rewrite Rules Inspector on WordPress.org

  3. Reserved Term Alert: There's a bunch of terms WP likes to keep to itself. "video" is safe, but always worth a double-check. Here’s the list I'm talking about on the WordPress Codex: Reserved Terms

  4. Server Shenanigans: The server can sometimes be the culprit. Cached configurations, NGINX setups, or other server-level settings might be meddling with your permalinks.

  5. Go Debug Mode: If you're feeling like a detective, turning on WP_DEBUG in wp-config.php can give you some insightful clues. Just remember to turn it off after!

  6. Nested CPT Issues: WordPress isn't a huge fan of nested custom post types by default. Maybe it's having a hiccup with your current setup?

That "resources" vs. "resource" quirk is proper weird. Classic WordPress curveball, right? If you do decide to dive back in, maybe rethink the structure slightly. And always, always backup before trying anything spicy!

Catch you on the flip side and happy coding! 🚀

4
  • alexandrucarjan LOL .. "WordPress is like a box of chocolates, you never know what you're gonna get!" .. aint that the truth.
    – Mitch S
    Commented Oct 21, 2023 at 2:08
  • And here's a new chocolate that's tasting a little funky .. After switching the videos slugs and getting the archive and singles working, the pagination on the archive is returning a 404. :: FACEPALM :: So .. i went into the CPT settings in ACF PRO and removed the custom rewrite. I set it to use the "default" post type key (which is "video") and just set the post type archive slug to "videos'. I then edited the custom breadcrumbs used by RankMath AND flushed the permalinks. Same issue. Page 2 of the archive returns a 404 error. :: again FACEPALM ::
    – Mitch S
    Commented Oct 21, 2023 at 2:15
  • To test .. I did the same thing with a different CPT that was completely working - the archive, pagination and single posts .. no problems all nested under the resources. The CPT is named "Events". After my edits, and setting it exactly like the videos - it still works. Wrap your head around that one.
    – Mitch S
    Commented Oct 21, 2023 at 2:15
  • I have another CPT: Datasheets. It's working just fine, just the like the Events CPT. And it's still nested under resources: stg-patraprime-patradev.kinsta.cloud/resources/datasheets. Again, wrap your head around that...!
    – Mitch S
    Commented Oct 21, 2023 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.