Custom Post Types return 404 in Frontity custom slug not found


So I got custom post types working. However, the custom post types “sub” never load and continually try to fetch. I can tell this is happening because the isFetchng remains true, no errors show up or anything else.

Note: Mac
Using: Mars Theme as a base

If I trigger a refresh, the page stops fetching and loads into the browser.

Is there a reason why this is happening?

Getting an error message in my terminal as well:
ServerError: post type from endpoints “posts,pages,media” with slug “css2” not found
at Object.eval (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/postType.ts:37:21)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at eval (webpack-internal:///./node_modules/@frontity/wp-source/src/actions.ts:22:101) {
status: 404,
statusText: ‘post type from endpoints “posts,pages,media” with slug “css2” not found’
Screen Shot 2020-10-12 at 9.18.24 PM

Hi @chayce.solchaga :wave: !

Could you provide a repo to be able to take a look.

If you can’t share your whole project, please create a CodeSandbox (you can start with this template) or a GitHub repository with the minimal amount of code to reproduce the issue.

1 Like

Hi @mmczaplinski

Here’s a link to my repo. I have one pull request open but its just the server.js files changes when I served it to vercel:

Here it is as is on Vercel so you can see what the endless loading looks like - as you can see it will endlessly reload until you refresh whenever you navigate to my custom post types on Property Owners and Renters:

Here is what my config looks like for my custom post type named “sub”:
indent preformatted text by 4 spaces

function cptui_register_my_cpts_sub() {

 * Post Type: subs.

$labels = [
	"name" => __( "subs", "twentytwenty" ),
	"singular_name" => __( "sub", "twentytwenty" ),
	"menu_name" => __( "Sub Content", "twentytwenty" ),
	"all_items" => __( "All sub content", "twentytwenty" ),
	"add_new" => __( "Add new", "twentytwenty" ),
	"add_new_item" => __( "Add new sub", "twentytwenty" ),
	"edit_item" => __( "Edit sub", "twentytwenty" ),
	"new_item" => __( "New sub", "twentytwenty" ),
	"view_item" => __( "View sub", "twentytwenty" ),
	"view_items" => __( "View subs", "twentytwenty" ),
	"search_items" => __( "Search subs", "twentytwenty" ),
	"not_found" => __( "No subs found", "twentytwenty" ),
	"not_found_in_trash" => __( "No subs found in trash", "twentytwenty" ),
	"parent" => __( "Parent sub:", "twentytwenty" ),
	"featured_image" => __( "Featured image for this sub", "twentytwenty" ),
	"set_featured_image" => __( "Set featured image for this sub", "twentytwenty" ),
	"remove_featured_image" => __( "Remove featured image for this sub", "twentytwenty" ),
	"use_featured_image" => __( "Use as featured image for this sub", "twentytwenty" ),
	"archives" => __( "sub archives", "twentytwenty" ),
	"insert_into_item" => __( "Insert into sub", "twentytwenty" ),
	"uploaded_to_this_item" => __( "Upload to this sub", "twentytwenty" ),
	"filter_items_list" => __( "Filter subs list", "twentytwenty" ),
	"items_list_navigation" => __( "subs list navigation", "twentytwenty" ),
	"items_list" => __( "subs list", "twentytwenty" ),
	"attributes" => __( "subs attributes", "twentytwenty" ),
	"name_admin_bar" => __( "sub", "twentytwenty" ),
	"item_published" => __( "sub published", "twentytwenty" ),
	"item_published_privately" => __( "sub published privately.", "twentytwenty" ),
	"item_reverted_to_draft" => __( "sub reverted to draft.", "twentytwenty" ),
	"item_scheduled" => __( "sub scheduled", "twentytwenty" ),
	"item_updated" => __( "sub updated.", "twentytwenty" ),
	"parent_item_colon" => __( "Parent sub:", "twentytwenty" ),

$args = [
	"label" => __( "subs", "twentytwenty" ),
	"labels" => $labels,
	"description" => "subcontent",
	"public" => true,
	"publicly_queryable" => true,
	"show_ui" => true,
	"show_in_rest" => true,
	"rest_base" => "sub",
	"rest_controller_class" => "WP_REST_Posts_Controller",
	"has_archive" => false,
	"show_in_menu" => true,
	"show_in_nav_menus" => true,
	"delete_with_user" => false,
	"exclude_from_search" => false,
	"capability_type" => "post",
	"map_meta_cap" => true,
	"hierarchical" => false,
	"rewrite" => [ "slug" => "sub", "with_front" => true ],
	"query_var" => true,
	"supports" => [ "title", "editor", "thumbnail", "trackbacks", "custom-fields", "author", "page-attributes", "post-formats" ],
	"taxonomies" => [ "category", "post_tag" ],

register_post_type( "sub", $args );

add_action( 'init', 'cptui_register_my_cpts_sub' );

I should point out that I found a similar post Custom Post Types returning 500 Error. I am also getting that error in my dev tools:

Uncaught (in promise) TypeError: Cannot read property 'split' of undefined
at __webpack_exports__.default (capitalize.ts?adee:3)
at Object.eval (postType.ts?e855:113)
at (<anonymous>)
at asyncGeneratorStep (postType.ts:4)
at _next (postType.ts:4)
at eval (postType.ts:4)
at new Promise (<anonymous>)
at Object.eval (postType.ts:4)
at Object.eval [as func] (postType.ts?e855:41)
at eval (actions.ts?f1c8:79)

I think that your problem is this error over here:

Can you see the same warning using your production app at: ?

The issue is that you have set your state.source.api with http instead of https in your frontity.settings.js.

For this reason, you can load the page when you go directly to e.g. The data for that request is loaded on the server and the server does not care whether you load it over http or https.

However, when you go to your homepage and try to navigate to “For Property Owners”, the data is being loaded on the client and your browser does care about this so the data never gets loaded, so you keep seeing the spinner! :sweat_smile:

I think that you also have another problem which is unrelated to what I mention above.

The error message that you have posted was:

ServerError: post type from endpoints "posts, pages, media" with slug "css2" not found

Looking through your repo the only mention of css2 is in this CSS file so I think you have somehow misconfigured static file serving.

That said, in order to solve this I would just recommend not serving the fonts from google fonts servers but rather serving them from your own server (I guess in your case it’s vercel :slight_smile: ). This should result in slightly better performance. My colleague Mario has written about it in another thread so you can check out how we handle it in the Frontity’s own twentytwenty theme!

Hope this helps!

1 Like

Hi @mmczaplinski

Great advice! I SSL’d my site, and got it on https, and also removed the other css2 slug error.

The last error in dev tools I’m getting is something similar to another post I tagged on this thread. When I click from any link to the other, it still does the endless loading.
What could be the culprit? Could it be because I am using my sub custom post types as the links in the main menu? Should I be pointing them in a different way?

i.e. about, property-owners and renters is /sub/about/ and so on.

Uncaught (in promise) TypeError: Cannot read property 'split' of undefined
at __webpack_exports__.default (capitalize.ts?adee:3)
at Object.eval (postType.ts?e855:118)
at (<anonymous>)
at asyncGeneratorStep (postType.ts:4)
at _next (postType.ts:4)
at eval (postType.ts:4)
at new Promise (<anonymous>)
at Object.eval (postType.ts:4)
at Object.eval [as func] (postType.ts?e855:41)
at eval (actions.ts?f1c8:88)

wondering if my issue ties into anything with this even though marked as resolved?

Hey @chayce.solchaga

It’s not really clear to me why that might be happening to be honest. :confused:

Have you configured your WP backend to to register the custom post types and also to register the custom taxonomy like explained in the Custom Post Types Frontity Talks video? I can only see the custom post type registration in the code that you’ve pasted above.

EDIT: My colleague Michael has confirmed that this is most likely an issue caused by not defining the taxonomies and CPTs correctly. I ll refer you to the video I mentioned for more details.

Hope this helps! :slight_smile:

Hey @chayce.solchaga !

Looks like there are a couple of issues here:

  1. It seems that you have created a taxonomy with the same name and endpoint as your Custom Post Type. This is not correct and will cause the REST API to return incorrect data. You can either remove the custom taxonomy altogether and then remove it from your frontity.settings.js file OR rename your taxonomy to something else. If you choose to rename your taxonomy, make sure that you have attached that taxonomy correctly to your custom post type.

  2. When you specify the homepage in your frontity.settings.js file, you have to also specify the postsPage property. Based on your current settings I am guessing that the postsPage: "/blog" should be correct? :slight_smile:

Hope this helps! :slight_smile:

@mmczaplinski and @mburridge

Thank you so much! That resolved the endless fetching issue. I reviewed the video and took my time this time to implement what I needed.

I’ll share this to the showcases once this is complete.