In child theme, add CPT to custom taxonomy registered in parent theme


I’m using Divi with a child theme. Divi (parent theme) has a CPT called project and two custom taxonomies, project_category and project_tag.

In my child theme I created a CPT called external_project. I want this newly created CPT to share the same taxonomies that the built-in Projects post type has. When registering this CPT I added 'taxonomies' => array( 'project_category', 'project_tag' ), to the args. But they’re not showing up. So I’m assuming I also need to add this newly created CPT to the array of object types the custom taxonomy is associated with.

I tried the following. I didn’t think it would work but I just wanted to try something, and of course it didn’t work. So don’t judge me too hard for it lol

function add_cpt_to_project_tax() {
    register_taxonomy('project_category', array('project', 'external_project'));
    register_taxonomy('project_tag', array('project', 'external_project'));
add_action('after_setup_theme', 'add_cpt_to_project_tax');

So my question is…Does anyone know of a hook or function I can create that will add the newly created CPT in my child theme, to the custom taxonomy registered in the parent theme? I’m having a tough time finding any examples online or anything in the codex that will help with my specific scenario. Any help would be greatly appreciated.

Ryan Patterson 2 months 0 Answers 11 views 0

Leave an answer