No rank-math.php file and functions.php overwrites

#621151
  • Resolved Anonymous
    Rank Math free

    In ticket #619856 I was instructed to follow these instructions to disable some of the optimization checks by going here: https://rankmath.com/kb/disable-seo-content-tests/

    I followed the instructions provided, but I didn’t have a rank-math.php, so I added it to functions.php per the instructions and it worked great. Up until something updated/overwrote the functions.php file and all my edits disappeared. How do I get the rank-math.php file in the list so this doesn’t happen again? Thanks!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Anonymous
    Rank Math free

    Ok, so I created the rank-math.php file as it didn’t exist and added the following, but it doesn’t seem to work. I tried to follow this link: https://rankmath.com/kb/filters-hooks-api-developer/

    What am I missing?

    <?php
    /**
    * Rank Math modifications
    */

    /** Filters for SEO checks */
    add_filter( ‘rank_math/researches/tests’, function( $tests, $type ) {
    unset(
    $tests[‘titleHasNumber’],
    $tests[‘contentHasTOC’],
    $tests[‘titleSentiment’],
    $tests[‘titleHasPowerWords’],
    unset($tests[‘hasContentAI’]
    );
    return $tests;
    }, 10, 2 );

    ?>

    Hello,

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

    It seems that the issue here is due to the unset value for the Content AI. The final code should look like this:

    <?php
    /**
    * Rank Math modifications
    */
    
    /** Filters for SEO checks */
    add_filter( 'rank_math/researches/tests', function( $tests, $type ) {
    unset(
    $tests['titleHasNumber'],
    $tests['contentHasTOC'],
    $tests['titleSentiment'],
    $tests['titleHasPowerWords'],
    $tests['hasContentAI']
    	);
    return $tests;
    }, 10, 2 );
    ?>

    You can also use the plugin Code Snippets to make sure that the changes are saved even if the theme is changed or updated. If you plan on using the plugin, you will not need to add the <?php value as well as the closing tag. (?>) So the final code should look like this:

    /**
    * Rank Math modifications
    */
    
    /** Filters for SEO checks */
    add_filter( 'rank_math/researches/tests', function( $tests, $type ) {
    unset(
    $tests['titleHasNumber'],
    $tests['contentHasTOC'],
    $tests['titleSentiment'],
    $tests['titleHasPowerWords'],
    $tests['hasContentAI']
    	);
    return $tests;
    }, 10, 2 );

    Hope that helps and please do not hesitate to let us know if you need my 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 2 replies - 1 through 2 (of 2 total)

The ticket ‘No rank-math.php file and functions.php overwrites’ is closed to new replies.