Rank Math UI not reflecting noindex and nofollow meta from update_post_meta

#1038009
  • Resolved Leon Rañon
    Rank Math free

    Dear Rank Math Support Team,

    We are experiencing an issue where noindex and nofollow directives, which are correctly being written to the WordPress database via update_post_meta(), are not being reflected or displayed correctly within the Rank Math interface for specific posts.

    We have thoroughly debugged our custom integration and confirmed that the data is being stored and retrieved correctly by WordPress core functions.

    Here’s a summary of our findings and evidence:

    1. Our Plugin Successfully Writes the Data:
    Our custom plugin processes markdown files, extracting robots directives from the front matter (e.g., [‘nofollow’, ‘noindex’]). It then uses update_post_meta() to set the rank_math_robots and rank_math_nofollow post meta values.

    debug.log

    2. Database Confirmation:
    We have directly inspected the wp_postmeta table in the database for the affected post (e.g., Post ID 41304) and can confirm that the meta_key rank_math_robots is set to noindex and rank_math_nofollow is set to 1.

    database

    3. WordPress Core get_post_meta() Confirms Data Retrieval:
    To verify that WordPress can correctly access these values, we’ve added debug logging using get_post_meta(). The logs clearly show that WordPress retrieves the intended values.

    Relevant Debug Log Snippets (from debug.log):

    When update_post_meta is called:

    [28-May-2025 05:00:13 UTC] Rank Math meta updated for Post ID 41304: robots=’noindex’ (Result: Fail, DB Error: ”, Rows Affected: 0), nofollow=’1′ (Result: Fail, DB Error: ”, Rows Affected: 0) (from front matter: ‘[“nofollow”,”noindex”]’)
    (Note: “Result: Fail, DB Error: ”, Rows Affected: 0)” is expected when the values are already correctly set, indicating no change was needed.)

    When get_post_meta is called to retrieve the values:

    [28-May-2025 05:00:13 UTC] DEBUG: Retrieved meta for Post ID 41304: rank_math_robots=’noindex’, rank_math_nofollow=’1′
    This log confirms that rank_math_robots is retrieved as ‘noindex’ and rank_math_nofollow is retrieved as ‘1’ (which corresponds to nofollow).

    4. Rank Math UI Discrepancy:
    Despite the data being correctly stored and retrieved by WordPress, when we view the Post Edit screen for Post ID 41304, the Rank Math SEO settings (specifically the “Robots Meta” and “Links Meta” options within the “Advanced” tab) do not reflect “No Index” and “No Follow.” They appear to be set to their default “Index” and “Follow” states or display incorrectly.

    rankmath gui

    WordPress Version: 6.8
    Rank Math SEO Version: 1.0.245
    PHP Version: 8.1
    Hosting Provider: SiteGround
    Site URL: https://staging30.salesfornicepeople.com/

    We kindly request your assistance in investigating why Rank Math’s user interface is not accurately reflecting the rank_math_robots and rank_math_nofollow post meta values that are demonstrably present and retrievable in the database.

    Thank you for your time and support.

    Sincerely,
    Leon

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    Please try updating the meta using the following line:

    
    update_post_meta($post_id, 'rank_math_robots', ['noindex']);

    If that doesn’t do it, please use the following code instead:

    
    update_post_meta($post_id, 'rank_math_robots', serialize(['noindex']));

    Let us know how that goes. Looking forward to helping you.

    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 1 replies (of 1 total)

The ticket ‘Rank Math UI not reflecting noindex and nofollow meta from update_post_meta’ is closed to new replies.