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.