Custom field rank_math_robots not working

#758751
  • Resolved Albert
    Rank Math free

    Hi, I’m trying to set a page to noindex using the custom field “rank_math_robots” and setting the value to “noindex”. The custom field is set correctly but the page keeps “index”, so it doesn’t have any effect.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello, I’m sorry to hear that you’re facing an issue with setting a page to noindex using the custom field “rank_math_robots” with the value “noindex.”

    To ensure that the custom field “rank_math_robots” works correctly to set a page to noindex, please follow these steps:

    1. Open the post/page in the WordPress Editor.
    2. Check if the Rank Math Metabox is available. If not, ensure that you’ve enabled “Add SEO Controls” from “Rank Math SEO → Titles & Meta Settings → Pages.”
    3. In the Rank Math Metabox, navigate to the Advanced Tab. If you cannot find the Advanced tab, please enable the advanced mode from “Rank Math SEO → Dashboard.”
    4. Check if the Robots Meta is set to “No Index.” If it is not set, select the “Index” checkbox, as shown in the screenshot below, and update the page/post.

    Advanced tab

    If after following these steps, the issue persists, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further. Thank you for bringing this concern to our attention.

    Sources:
    Fix Excluded by NoIndex Tag – Google Search Console Status » Rank Math
    How to Fix the “Indexed, though blocked by robots.txt” Error » Rank Math
    How to Noindex URLs With Rank Math » Rank Math
    Rank Math Sitemap Issues and Their Fixes » Rank Math

    Albert
    Rank Math free

    I don’t want to use the metabox. I need to use the custom field as I want to create multiple pages programatically and set those I want to be noindex with the custom field

    Hello,

    That option will not work for old post/pages/CPTs. You can set it to noindex from the pages/posts list page. For PRO users they can configure this for multiple posts using the bulk option or CSV import.

    You can also apply the noindex tag dynamically. Here’s an example code to use the filter for multiple URLs at a time:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
            // Get the current page URL
            $current_url = home_url( $_SERVER['REQUEST_URI'] );
            
            // Define an array of pages to change the robots tag to noindex
            $pages = array(
                    'https://example.com/page1',
                    'https://example.com/page2'
            );
            
            // Check if the current page is in the array
            if ( in_array( $current_url, $pages ) ) {
                    // Change the robots tag to noindex
                    $robots['index'] = 'noindex';
            }
            
            // Return the modified robots array
            return $robots;
    });

    Remember to change the example.com URLs to the URLs you want to dynamically set to noindex. You can also add more URLs. You can add the code to your site using any of the methods here:https://rankmath.com/kb/wordpress-hooks-actions-filters/.

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

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Custom field rank_math_robots not working’ is closed to new replies.