• Resolved mcdeth

    (@mcdeth)


    Hello, when the product is withdrawn from sale, I want to set it as hidden. Unfortunatelly, rank math sets noindex and nofollow. There’s no point in nofollow, so I tried changing robots with functions.php, in this case I tried changing all follow links for testing purpose

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    $robots["index"] = 'index';
    $robots["follow"] = 'follow';
    return $robots;
    });

    No changes, this snippet however:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    $robots['index'] = 'index';
    $robots['index'] = 'index';
    return $robots;
    },999 );

    It adds additional robots:

    <meta name=”robots” content=”noindex, nofollow, follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large”/>

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mcdeth

    (@mcdeth)

    I also tried without any luck

    add_filter( 'rank_math/frontend/robots', function( $robots ) { if(is_product()) { $robots = ['index' => 'noindex', 'follow' => 'nofollow', 'imageindex' => 'noimageindex', 'archive' => 'noarchive' ]; return $robots; } return $robots; });
    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @mcdeth,

    Thank you for contacting Rank Math support.

    If you don’t want the hidden products to be set to noindex, navigate to WP Dashboard > Rank Math SEO > General Settings > WooCommerce and disable the Noindex Hidden Products option.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Thread Starter mcdeth

    (@mcdeth)

    Thanks, I want it to be noindex, but I want it to be follow

    Plugin Support Rank Math Support

    (@rankmathsupport)

    Hello @mcdeth,

    You can use the following filter to set the hidden products as follow:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    if ( ! is_product() ) {
    return $robots;
    }

    $product = \wc_get_product();
    $is_hidden = $product && $product->get_catalog_visibility() === 'hidden';
    if ( $is_hidden ) {
    $robots['nofollow'] = 'follow';
    }

    return $robots;
    }, 11 );

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.