-
AuthorPosts
-
September 19, 2017 at 7:12 pm #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
September 22, 2017 at 5:51 am #855158Hey 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,
IsmaelSeptember 26, 2017 at 5:01 pm #857017Hi 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.
- This reply was modified 7 years, 1 month ago by realisedesign.
September 27, 2017 at 6:06 am #857311Hi,
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,
IsmaelSeptember 27, 2017 at 8:26 am #857358Hi 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!
September 28, 2017 at 5:26 am #857845Hi,
Thank you for the update. We added the filter. Please remove browser cache or hard refresh before checking the page.
Best regards,
IsmaelSeptember 28, 2017 at 8:18 am #857888Hi 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
September 29, 2017 at 10:13 am #858380Hi,
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,
IsmaelOctober 3, 2017 at 9:39 am #859529That’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!
October 3, 2017 at 10:39 am #859566 -
AuthorPosts
- The topic ‘De-registering portfolio categories’ is closed to new replies.