Hello @drmrgood
Thanks for using the Yoast SEO plugin. Though we’re unfamiliar with Classima theme & Classified Listing Pro, you should see settings related to the custom post types and taxonomies in WordPress > Yoast SEO > Settings > Content Types/Categories and Tags. Then you can set them to noindex by toggling the button to Show [taxonomy] in search results
Do let us know how it goes.
As you can see here:
See https://i.ibb.co/myQZS6R/novo.jpg
I have an option for Listings Categories and Listing Locations in Yoast SEO. All I need is that empty categories and locations are noindex.
I tried this code in functions.php but it doesn’t work:
// Noindex empty locations
add_action(‘wp_head’, ‘noindex_empty_locations’);
function noindex_empty_locations() {
global $post;
if( is_singular(‘listing’) && ( !has_term( array(), ‘listing-location’, $post->ID ) ) ) {
echo ”;
}
}
// Noindex empty listings
add_action(‘wp_head’, ‘noindex_empty_listings’);
function noindex_empty_listings() {
global $post;
if( is_singular(‘listing’) && ( !has_term( array(), ‘listing-category’, $post->ID ) ) ) {
echo ”;
}
}
-
This reply was modified 3 years ago by
drmrgood.
I cannot review your custom code; you may want to speak with a web developer. However, by default if you have an empty listing category, that is, a category with 0 listings, this will automatically be excluded from the sitemap. You may take a look at our sitemap API since you have specific requirements not catered to in the plugin settings UI.
I successfully resolve this with this code:
add_filter(‘wpseo_robots’, ‘yoast_my_noindex’, 999); function yoast_my_noindex($string= “”) { if ( have_posts() == false ){$string= “noindex, follow”;} return $string; }