Custom Post Types - Display Global Block in new Post Type

Good Day,

I’m new to creating custom post types and need some assistance.

I’m creating user submitted posts via WP Forms, ACF Pro and CPT UI.
And have pretty much gotten everything to work.

Filled in forms are being correctly displayed as posts by including the following code in my functions.php file.

/** Add Global Block to Casting Posts */
function add_global_post() {   
    if(in_category('castings')){
  echo do_shortcode('[cs_gb name="casting-info"]');
}}
add_action( 'x_after_the_content_end', 'add_global_post', 10 );

However, I’ve had to create an additional Custom Post Type called ‘Castings’ and gave the CPT a category called ‘auditions’

But when updating the functions.php file to use the new category, It doesn’t display the global block on the newly created posts. (See code below),

/** Add Global Block to Casting Posts */
function add_global_post() {   
    if(in_category('auditions')){
  echo do_shortcode('[cs_gb name="casting-info"]');
}}
add_action( 'x_after_the_content_end', 'add_global_post', 10 );

I’ve tried updating the line to say
'if{in_casting_category('auditions')){
But with no success.

I’ve spent the last two days trying to figure out how to do this by myself but with no avail.
I was hoping to could take a moment, and let me know what I am doing wrong.

Also, I’ve noticed that the new Custom Post Type is not displaying the meta icons (or category icons) in the new posts. Any guidance on how I can get them to show up in the new post type would be much appreciated.

Thank you and regards,

Julius

Hello Julius,

The in_category('auditions') is a condition that you can use to know if a post or custom post type belongs to the Auditions category. You can check the codex here:

Please be advised that you have extended the theme’s functionality with custom coding. This is beyond the scope of our support already. We are only limited to getting your site setup, bug fixes, and minor cosmetic changes. Any issues related to a custom code and further enhancement of the code must be directed to a 3rd party developer.

Note: We are unable to provide support for customizations under our Support Policy. If you are unfamiliar with code and resolving potential conflicts, you may select our One service for further assistance.

Thank you for your understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.