Warning detected when activating rank math on an older site

#757072
  • Resolved Adam Larsson
    Rank Math free

    When i activated the plugin, wordpress said this:

    The plugin generated 428 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

    I saw in the header in the plugins page after activating the plugin this;

    specific categories */ add_filter( ‘rank_math/frontend/robots’, function ( $robots ) { $categories = array_map( function ( $category ) { return $category->slug; }, get_the_category() ); //Replace your_category with your category slug. if ( in_array( ‘donotallowpost’, $categories ) ) { unset( $robots[‘index’] ); $robots[‘noindex’] = ‘noindex’; } return $robots; } );

    My Query monitor reported the data in the Sensitive data section

    I also have a rank-math.php in my theme directory

    /**
    * Filter to set noindex to specific categories
    */
    add_filter( 'rank_math/frontend/robots', function ( $robots ) {
    $categories = array_map( function ( $category ) {
    return $category->slug;
    }, get_the_category() );

    //Replace your_category with your category slug.
    if ( in_array( 'donotallowpost', $categories ) ) {
    unset( $robots['index'] );
    $robots['noindex'] = 'noindex';
    }
    return $robots;
    } );

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    I apologize for the issue you are facing with Rank Math on your older site. The unexpected output during activation might be due to the code snippet you shared that sets noindex for specific categories.

    To resolve this issue, you can follow these steps:

    1. Check Code Snippets: Ensure that the code snippets added to your theme files or functions.php are correct and do not generate any unexpected output.

    2. Update Code Snippets: If you are using the code snippet to set noindex for specific categories, make sure to replace 'donotallowpost' with the actual category slug you want to target.

    3. Verify Sensitive Data: If your Query Monitor reported sensitive data, review the information shared and ensure it does not expose any critical details.

    If the issue persists after checking and updating the code snippets, please consider reviewing the code for any errors or conflicts. If needed, you can assign this ticket to a human agent for further assistance by using the available buttons.

    Thank you for bringing this concern to our attention. Let us know if you need any further help.

    Closing spiel: We are here to help you with any Rank Math-related queries or concerns.

    Sources:
    How to NoIndex All Posts in a Category » Rank Math
    How to Make Your Theme Rank Math Compatible » Rank Math
    Rank Math Sitemap Issues and Their Fixes » Rank Math
    How to Use the Noydir Robots Meta Tag » Rank Math
    The #1 WordPress SEO Plugin in 2023 – Rank Math

    Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    The filter you’ve shared is to Noindex posts under the donotallowpost category. As it is included in the rank-math.php file, please make sure the <?php is added in the first line of this code.

    If the issue persists, please remove the rank-math.php file from your theme folder and after activating the plugin, you can use the Code Snippet plugin to add the filter to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/#code-snippets-plugin

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

    Thank you.

    O holy sh…. I can’t believe I forgot the <?PHP.. dang… Well, it’s not complaining anymore..

    Hello,

    We are super happy this resolved your issue.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

You must be logged in to reply to this ticket.