Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #853742

    guy_b
    Participant

    Is it possible to deregister the “x portfolio” post type?

    ..and if so, will this have other consequences?

    I tried the following, but it didn’t work (so currently inconsequential I guess)!

    if ( ! function_exists( 'unregister_post_type' ) ) :
    function unregister_post_type() {
        global $wp_post_types;
        if ( isset( $wp_post_types[ 'x-portfolio' ] ) ) {
            unset( $wp_post_types[ 'x-portfolio' ] );
            return true;
        }
        return false;
    }
    endif;
    
    add_action('init', 'unregister_post_type',100);
    #853882

    Rue Nel
    Moderator

    Hello There,

    Thanks for writing in! It may not be possible as X needs it for the portfolio items. You may try this code:

    add_action( 'after_setup_theme','remove_x_portfolio', 100 );
    
    function remove_x_portfolio() {   
        remove_action( 'init', 'x_portfolio_init');    
    }

    We would loved to know if this has work for you. Thank you.

    #854436

    guy_b
    Participant

    Hi, many thanks..

    I would prefer not to do the remove action to unhook the init..

    As you mentioned, it is hooked into X.. so I think trying to unhook it may have undesired effects on the Theme functionality (that you or I are unaware of without deeper testing).

    I was hoping to unregister it rather than unhook..

    Ok, not a problem, I think I’ll rather just add a dismissable warning message via a custom field at the top of the post type to alert the client that they should not use the Portfolio post type.

    #854614

    Rad
    Moderator

    Hi there,

    It’s not unhooking the init, it’s unhooking x_portfolio_init from init. And it has no effect to other hooks.

    The theme will register the post type, and then unregister it again and that is slower. Preventing it from registering it is more effective.

    Please note that hooks are only limited to each specific hook, it doesn’t have any connection to other hooks. Hooks are only affected if you have chains of multiple hooks that uses the same filter (chain filters). But this is is just action hook and not filter.

    Thanks!

    #855441

    guy_b
    Participant

    I see, thanks. Unfortunately is doesn’t work though..

    I am using a Child Theme if that makes any difference?

    I tried the function (and a couple of variations like with higher priority) in both the custom site functionality plugin, as well as in the child functions.php.

    No errors.. just no remove action.

    Any idea what it doesn’t work?

    #855895

    Christian
    Moderator

    Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

    Thank you for your understanding.