• Resolved drmrgood

    (@drmrgood)


    Hi!

    Classima theme authors claims that Yoast SEO is fully supported in their theme which is true and I successfully use Yoast.

    But I want to set up all empty categories and locations to noindex.

    Can you help me with some code I can put in functions.php file to achieve this?

    Thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    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.

    Thread Starter drmrgood

    (@drmrgood)

    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 1 year, 6 months ago by drmrgood.
    Plugin Support Maybellyne

    (@maybellyne)

    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.

    Thread Starter drmrgood

    (@drmrgood)

    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; }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Classima theme & Classified Listing Pro problem’ is closed to new replies.