Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #854001

    Hi there,

    I am trying to get rid of the portfolio categories in my child theme and also add the default categories to the portfolio items. I’ve added this code to my functions.php

    add_action('init','customise_portfolio_categories', 20);    
    function customise_portfolio_categories() {
        unregister_taxonomy( 'portfolio_entries' );
        register_taxonomy_for_object_type('category', 'portfolio');
    }

    Registering the taxonomy works fine as far as I can tell, but deregistering the portfolio_entries taxonomy chucks up this error on the Portfolios page in the backend (the page that lists all your portfolio entries):
    Catchable fatal error: Object of class WP_Error could not be converted to string in /var/sites/s/sandbox.realisedesign.co.uk/public_html/wp-content/themes/enfold/includes/admin/register-portfolio.php on line 118

    I’m guessing that unregistering the taxonomy in this way isn’t the right way to do it. Could you advise on a better approach please that I can do in my child theme’s functions.php file, so that it doesn’t get overwritten with any updates later down the line.

    Thank you, and thanks for the great theme by the way, I’m a really big fan. :0)

    Kind regards,

    Hannah

    #855158

    Hey realisedesign,

    Thank you for using Enfold.

    Please use the following function to deregister the taxonomy.

    function ava_deregister_taxonomy(){
    	global $wp_taxonomies;
    	if ( taxonomy_exists( 'portfolio_entries' ) ) unset( $wp_taxonomies['portfolio_entries'] );
    }
    add_action( 'init', 'ava_deregister_taxonomy', 30);

    Best regards,
    Ismael

    #857017

    Hi Ismael,

    Thanks for sending this code through but when I add it to functions.php I get the same issue as before. My Portfolio items list ends up generating errors on the admin page. I don’t think it likes it! Here’s a screenshot of what I see.

    I’ve taken the code out of functions.php as others are working on the content in the meantime, but my admin and FTP credentials are in a private message if you want to take a look.

    Error message on Portfolio items

    #857311

    Hi,

    The screenshot is missing or invalid. What is the error? The code works fine on our installation. I tried to access the site via FTP but I’m not sure where to look. There’s a lot of unrelated directories in the file server.

    Best regards,
    Ismael

    #857358

    Hi Ismael,

    Here is the error image on my GoogleDrive, hopefully you can click this link and see it https://drive.google.com/file/d/0B09jSyy0S1omS3RPd1hLbFRMYk0/view?usp=sharing

    I’ve updated the FTP directory you need to go to to see my child theme. Apologies for not providing that earlier!

    #857845

    Hi,

    Thank you for the update. We added the filter. Please remove browser cache or hard refresh before checking the page.

    Best regards,
    Ismael

    #857888

    Hi Ismael,

    Thank you for doing this. I have done a hard refresh in my browser, and even used a different browser and done a hard refresh on that too – but still have the same error message on the portfolio items as before. Can you see it?

    So my portfolio items looks like this: https://drive.google.com/file/d/0B09jSyy0S1omS3RPd1hLbFRMYk0/view?usp=sharing

    If you log in and look at that page can you see the errors too?

    Kind regards,

    Hannah

    #858380

    Hi,

    I’m sorry but I didn’t the error. We replaced the code with the following.

    add_action('init','customise_portfolio_categories', 20);
    function customise_portfolio_categories() {
        register_taxonomy_for_object_type('category', 'portfolio');
        unregister_taxonomy_for_object_type( 'portfolio_entries', 'portfolio' );
    }

    Best regards,
    Ismael

    #859529

    That’s brilliant! Thank you so much for your help with this. That’s fixed the issue and my client won’t be confused by the two sets of categories now. I really appreciate it!

    #859566

    Hi,

    Glad it is working. Please open a new thread if you need anything else. :)

    Best regards,
    Ismael

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘De-registering portfolio categories’ is closed to new replies.