Prevent /portfolio-item/ from being indexed

Hello,
Many of our sites do not use the portfolio items, but that /portfolio-item/ page is still automatically available to robots. We can’t add a disallow rule in the robots.txt, because multiple sites share it (some use the portfolio items, others don’t).
https://www.magikweb.ca/portfolio-item

Is there any way (functions.php?) to entirely remove that page / post type or to block it from being indexed?

Thank you for any insight!

Hello @magikweb,

If you do not need the portfolio custom type, you may disable it on the website. To do that, Please install and activate the child theme and login through FTP then edit the functions.php then add this code:

function delete_post_type(){
    unregister_post_type( 'x-portfolio' );
    unregister_taxonomy( 'portfolio-tag' );
    unregister_taxonomy( 'portfolio-category' );
}
add_action('init','delete_post_type', 9999);

Kindly note that since this is a custom code that changes the default behavior/display of the theme, you will be responsible to maintain or update the code in case you require further changes or if the code stops working in future updates. If you are uncertain how to proceed, it would be best to get in touch with a developer.

Hope this helps.

1 Like

Thank you, that did the trick! :slight_smile:

We are delighted to assist you with this.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.