I'm trying to unregister a post type from a child theme but I haven't been able to do so, the code in the funcions.php file on the parent theme is something like this:

add_action( 'init', 'mc_projects' );
function mc_projects() {
    register_post_type( 'project', array(
        // Default options....
    ) );


What I tried to do in my child theme was to remove the mc_project action from the init hook like this:

remove_action('init', 'mc_projects', 11);

But it didn't work, even when I set the priority to some higher value, am I doing something wrong?

  • 1
    If i remember correct the the priority must match between both add_action and remove_action calls.
    – Bainternet
    Jun 6, 2011 at 22:52
  • 1
    To add some info: Default priority is 10.
    – kaiser
    Jun 7, 2011 at 17:07
  • Oh I thought it had to be higher than the action I wanted to remove, I'll try that Jun 7, 2011 at 19:04
  • No luck, could it be because the functions file on the child theme gets loaded before the parent theme functions? So I'm trying to remove an action that hasn't been declared yet? Jun 7, 2011 at 19:08

5 Answers 5


Try the following in your child theme functions file.

add_action( 'init', 'remove_mc_projects' );
function remove_mc_projects() {
    remove_action('init', 'mc_projects');

This helped me.

add_action( 'after_setup_theme','remove_project_custom_init', 100 );

function remove_project_custom_init() {
    remove_action( 'init', 'project_custom_init');

Credit goes to www.jasonpaul.net

  • This seems to be the right solution, when trying to run the "remove_project_custom_init()" on 'init', the function does nothing. It has to run on action 'after_setup_theme' to remove the parent theme function. Nov 4, 2014 at 20:24

Here's another solution, abeit a bit hackish -

In my parent theme, my custom post type is created like so:

if (!(function_exists('my_post_type')))
    function my_post_type()

Then, in my child theme, I simply re-declare the function as empty -

function my_post_type() { }

Hope this helps! This is my first contribution to a forum like this so please excuse any formatting rules I've broken.

  • Formatting perfectly fine. :) Hackish meets it ;)
    – kaiser
    Feb 20, 2012 at 15:17

no one above not work for me in Wordpress 4.9.7 but this solve my problem

function delete_post_type(){
  unregister_post_type( 'portfolio' );
add_action('init','delete_post_type', 100);

This worked for me.

function override_parent() {
remove_action( 'init', 'mc_projects', 0 );
add_action ('after_setup_theme','override_parent');
  • Please add an explanation to your answer: why could that solve the problem?
    – fuxia
    Sep 8, 2014 at 14:00

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.