Skip Navigation

[Resolved] What do I use for custom post type name

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user is using their CPT in a custom code but didn't know if they should use the Name of the CPT or the slug.

Solution:

In most cases what is required to be used is the slug of the CPT.

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.71 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by ashiA 5 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1192738

HI,

I am trying to use Jetpack's related post feature to work with custom post types created by toolset. Jetpack has documentation on the code that needs to be included in functions.php here: hidden link (will need to scroll to the bottom).

They ask to include this code in the function.php file

function allow_my_post_types($allowed_post_types) {
$allowed_post_types[] = 'your-post-type';
return $allowed_post_types;
}
add_filter( 'rest_api_allowed_post_types', 'allow_my_post_types' );

with an instruction to change 'your-post-type' to the name of the custom post type.

If I have created 3 custom post types via toolset (for e.g. books, videos & courses), I wanted to check
(a) how do I find the name I am supposed to use here (is it the name single, name plural, slug or a machine readable name that I can find somewhere)
(b) do I need to add the function code above 3 times for each custom post type, or can I add all 3 custom post types seperated by a comma

#1192759

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ashi,

Thank you for contacting our support forum.

I'm assuming that you would need to use the slug. Also yes you would need to create the function 3 times

1 instance for each CPT.

Thanks,
Shane

#1193119

My issue is resolved now. Thank you!