Skip to main content

Settings

1. Filter to change the Rank Math Metabox priority.

Use this filter to change the Rank Math metabox priority to low, so it appears after other metaboxes like ACF fields.

/**
* Change the Rank Math Metabox Priority
*
* @param array $priority Metabox Priority.
*/
add_filter( 'rank_math/metabox/priority', function( $priority ) {
return 'low';
});

2. Filter to change the Focus Keyword Limit

Use this filter to increase or decrease the number of maximum focus keywords that can be added to the single post or page editor.

/**
* Change the Focus Keyword Limit
*/
add_filter( 'rank_math/focus_keyword/maxtags', function() {
return 10; // Number of Focus Keywords.
});

3. Filter to add/remove section into the General Settings option panel.

This filter allows you to add or remove a section from the general settings options panel of the Rank Math plugin.

/**
* Allow developers to add new section into general setting option panel.
*
* @param array $tabs
*/
add_filter( 'rank_math/settings/general', function( $tabs) {
unset( $tabs['htaccess'] ); // Unsets Edit .htaccess tab.
return $tabs;
});

4. Filter to add/remove section into the Title Settings option panel.

You can add or remove a custom section to or from the Title Settings option panel with this setting.

/**
* Allow developers to add new section into general setting option panel.
*
* @param array $tabs
*/
add_filter( 'rank_math/settings/title', function( $tabs) {
return $tabs;
});

5. Filter to allow developers to add option fields to check against update. And if updated, flush the rewrite rules

/**
* Allow developers to add option fields to check against updatation.
* And if updated flush the rewrite rules.
*
* @param array $flush_fields Array of fields id for which we need to flush.
*/
add_filter( 'rank_math/flush_fields', function( $fields) {
return $fields;
});

6. Filter to allow developers to add new tabs into the options panel.

/**
* Allow developers to add new tabs into option panel.
*
* The dynamic part of hook is, page name without 'rank-math-' prefix.
*
* @param array $tabs
*/
add_filter( "rank_math/admin/options/{$filter}_tabs", function( $tabs ) {
return $tabs;
});

7. Filter to add/update/remove Content Analysis test.

This filter allows you to add/update/remove content analysis tests. For removing any test, you can simply unset the test as shown in this tutorial.

/**
* Allow developers to modify the test or score.
*
* @param array $tests Array of tests with score
* @param string $type Object type. Can be post, user or term.
*/
add_filter( 'rank_math/researches/tests', function( $tests, $type ) {
return $tests;
}, 10, 2 );

8. Filter to change a number of items to import per run. Used when importing data from other plugins

/**
* Number of items to import per run.
*
* @param int $items_per_page Default 100.
*/
add_filter( 'rank_math/importers/items_per_page', function( $items_per_page ) {
return $items_per_page;
});

9. Filter to add/remove the item from the Admin Bar node.

Add or remove an item from the WordPress admin-bar menu that Rank Math adds to the front-end of your WordPress website.

/**
* Add item to Rank Math admin bar node.
*
* @param array $items Array of nodes for Rank Math menu.
*/
add_filter( 'rank_math/admin_bar/items', function( $items ) {
return $items;
});

10. Add Default value for General Settings during plugin installation.

Set a default value for general settings when Rank Math is installed on a WP website. Refer to the options and default values here.

/**
* Add defaults for general options.
*
* @param array $settings Array of settings and its values.
*/
add_filter( 'rank_math/settings/defaults/general', function( $settings ) {
return $settings;
});

11. Add Default value for Title Settings during plugin installation.

Use this filter to set default values for SEO Title and Meta settings when Rank Math is installed on a website. Refer to the options and default values here.

/**
* Add defaults for title options.
*
* @param array $settings Array of settings and its values.
*/
add_filter( 'rank_math/settings/defaults/titles', function( $settings ) {
return $settings;
});

12. Add Default value for Sitemap Settings during plugin installation.

Use the filter to set default values for sitemap settings. Refer to the options and default values here.

/**
* Add defaults for Sitemap options.
*
* @param array $settings Array of settings and its values.
*/
add_filter( 'rank_math/settings/defaults/sitemap', function( $settings ) {
return $settings;
});

13. Allow developers to add/remove/change Modules.

/**
* Filters the array of modules available to be activated.
*
* @param array $modules Array of available modules.
*/
add_filter( 'rank_math/modules', function( $modules ) {
return $modules;
});

14. Filter to change the Author base.

Use this filter to change the URL base for author archives. When the author base is configured to use this filter, the Author Base set by the users under Rank Math SEO → Titles & Meta → Authors will not have any effect.

/**
* Allow developers to change the author base.
*
* @param string $base The author base.
*/
add_filter( 'rank_math/author_base', function( $base ) {
return $base;
});

15. Filter to change the address part format.

This filter lets you change the address part format for Rank Math’s Local SEO contact shortcode.

/**
* Allow developer to change the address part format.
*
* @param string $parts_format String format how to output address part.
*/
add_filter( 'rank_math/shortcode/contact/address_parts_format', function( $format ) {
return $format;
});

16. Filter to change the args in the locations query

This filter allows you to change the query arguments to retrieve locations when you use Location shortcode and Local Business Block in Rank Math.

/**
* Filter to change Locations query args.
*
* @param array $args Arguments to retrieve locations.
* @return array $args.
*/
add_filter( 'rank_math/location_args', function( $args ) {
// Add your code here to change the args.
return $args;
} );

17. Filter to change Post type icons in the options panel.

/**
* Allow developer to change post types icons.
*
* @param array $icons Array of available icons.
*/
add_filter( 'rank_math/post_type_icons', function( $icons ) {
return $icons;
});

18. Filter to change Taxonomy icons in the options panel.

/**
* Allow developer to change taxonomies icons.
*
* @param array $icons Array of available icons.
*/
add_filter( 'rank_math/taxonomy_icons', function( $icons ) {
return $icons;
});

19. Filter to enable/disable overlay icon option in Social Tab in Post Settings.

/**
* Allow developer to enable/disable overlay icon option in Post Settings.
*
* @param string $value Default is set to off.
* @param string $service Can be faceboo or twitter.
*
*/
add_filter( 'rank_math/metabox/social/overlay_icon', function( $value, $service ) {
return $value;
}, 10, 2 );

20. Filter to enable/disable Link Suggestion Metabox for the particular post type.

/**
* Allow developer to enable/disable Link Suggestion Metabox for specific post type.
*
* @param string $default Default is set to on.
* @param string $post_type Post type name.
*
*/
add_filter( 'rank_math/settings/titles/link_suggestions', function( $default, $post_type ) {
return $default;
}, 10, 2 );

21. Filter to set default Snippet type for the post type.

Use this filter to set a default Schema type for each post type under Rank Math SEO → Titles & Meta settings.

/**
* Allow developer to default Snippet type by post type.
*
* @param string $type Snippet Type.
* @param string $post_type Post type name.
*
*/
add_filter( 'rank_math/settings/snippet/type', function( $type, $post_type ) {
return $default;
}, 10, 2 );

22. Filter to set default Snippet Article type for the post type.

/**
* Allow developer to default Snippet Article type by post type.
*
* @param string $type Article Type.
* @param string $post_type Post type name.
*
*/
add_filter( 'rank_math/settings/snippet/article_type', function( $type, $post_type ) {
eturn $default;
}, 10, 2 );

23. Filter to add custom variable replacements.

Use this filter to modify namedescriptionvariable and example of existing Rank Math variables.

/**
* Filter to add custom variables
*/
add_filter( 'rank_math/vars/replacements', function( $vars ) {
return $vars;
});

24. Add Extra Variables to the Rank Math Dropdown in Title & Meta Settings

This filter allows you to add additional variables that would appear in the Rank Math Titles & Meta settings drop-down as well as in the Meta Box Snippet Editor.

/**
* Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
*/
add_action( 'rank_math/vars/register_extra_replacements', function(){
rank_math_register_var_replacement(
'custom_variable_slug',
[
'name' => esc_html__( 'Custom variable name.', 'rank-math' ),
'description' => esc_html__( 'Custom variable description.', 'rank-math' ),
'variable' => 'custom_variable_slug',
'example' => 'custom_variable_callback()',
],
'custom_variable_callback'
);
});

25. Filter to show/hide SEO Metabox.

/**
* Filter to show/hide SEO Metabox.
*/
add_filter( 'rank_math/metabox/add_seo_metabox', function( $default ) {
return $default;
});

26. Filter to change Separator %sep%.

This filter lets you set a default separator that is used in the title tags. If the separator character is set using this filter, then it will override the Separator Character set by users under Rank Math SEO → Titles & Meta → Global Meta.

/**
* Filter to change Separator %sep%.
*/
add_filter( 'rank_math/settings/title_separator', function( $sep ) {
return $sep;
});

27. Filter to turn off auto-update notification emails.

/**
* Filter to turn off auto-update notification emails.
*/
add_filter( 'rank_math/auto_update_send_email', '__return_false' );

28. Filter to edit the auto-update notification emails.

/**
* Filter to edit the auto-update notification emails.
*/
add_filter( 'rank_math/auto_update_email', function( $email, $version, $plugin_upgrader_obj ) {
$email['to_address'] = '[email protected]';
$email['body'] = "Rank Math has been updated to version {$version}.";
return $email;
});

29. Add Custom Power Words for Analysis

/**
* Filter to add custom Power Words
*/
add_filter( 'rank_math/metabox/power_words', function( $words ){
$new_words = [
'test-word1',
'test-word2',
'test-word3',
];
return array_merge( $words, $new_words );
});

30. Filter to change default Settings Mode(Easy or Advanced)

/**
* Filter to change default Settings Mode(Easy or Advanced)
*/
add_filter( 'rank_math/setup_mode', function( $mode ) {
return $mode;
});

31. Filters to change the CSV separator character in the CSV Importer file

/**
* Filter to change the CSV separator character in the CSV Importer file
*/
add_filter( 'rank_math/csv_import/separator', function( $separator ) {
return ';';
} );

32. Hide the Email Reporting Options

/**
* Filter to hide the Email Reporting Options
*/
add_filter( 'rank_math/analytics/hide_email_report_options', '__return_true' );

33. Use the admin email ID for Email Reporting

add_filter( 'rank_math/analytics/email_report_parameters', function( $data ) {
$data['to'] = get_option( 'admin_email' );
return $data;
} );

34. Change the Email SEO Report Button URL

add_filter( 'rank_math/analytics/email_report_variables', function( $vars ) {
$vars['report_url'] = "https:://newlogin-url.com";
return $vars;
} );

35. Google Analytics – Track certain user role even if Exclude Logged-In users option is ON

This filter overrides the Exclude logged-in users feature and lets you unset specific user roles from being ignored.

add_filter(
'rank_math/analytics/gtag_exclude_loggedin_roles',
function( $roles ) {
unset( $roles['customer'] ); // Track logged in customers.
return $roles;
}
);

36. Filter to change the Post Meta Table limit

/**
* Filter to change the Post Meta Table Limit
*/
add_filter(
'rank_math/seo_analysis/postmeta_table_limit',
function ( $limit ) {
return 500000;
}
);

37. Filter to allow line breaks in FAQ and HowTo Schema blocks

/**
* Filter: Allow developers to preserve line breaks.
*
* @param bool $return If set, this will convert all remaining line breaks after paragraphing.
* @param string $block Block name.
*/
add_filter( 'rank_math/block/preserve_line_breaks', '__return_false' );

38. Filter to Disable Domain Checking functionality

This filter bypasses the check for any mismatch in the Site Address and WordPress URL in the settings that can cause issues with activation on some setups.

/**
* Filter whether we need to check for URL mismatch or not.
*/
add_filter( 'rank_math/registration/do_url_check', '__return_false' );

39. Filter to Disable Sensitive Data Encryption

/**
* Filter to disable sensitive data encryption
*/
add_filter( 'rank_math/admin/sensitive_data_encryption', '__return_false' );

40. Filter to Disable Focus Keyword Suggestions from Google

/**
* Filter to Disable Keyword Suggestions from Google
*/
add_filter( 'rank_math/metabox/values', function( $args = [] ) {
$args['autoSuggestKeywords'] = false;
return $args;
} );

41. Filter to Modify the Redirection data before updating a Redirection

/**
* Filter to modify the redirection data before updating a redirection.
* Pass a false value to skip the update and create a new redirection instead.
*
* @param array|false $data Redirection data.
*/
add_filter('rank_math/admin/csv_import_redirection_update', function ($exist, $data) {
return $data;
}, 10, 2);

42. Filter to exclude post types from Analytics Index

Once you’ve made changes to the existing Analytics Index using this filter, be sure to rebuild the index by heading over to WordPress Dashboard → Rank Math SEO → Status & Tools → Database Tools → Rebuild Index.

/**
* Filter to exclude post types from Analytics Index.
*/
add_filter( 'rank_math/analytics/post_types', function( $post_types = [] ) {
$excludes = [
'page',
];

return array_diff_key( $post_types, array_flip( $excludes ) );
});

43. Filter to change IndexNow API Key location

/**
* Filter to change the location of the IndexNow key file.
*
* @param string $location Location.
*/
add_filter( 'rank_math/instant_indexing/indexnow_key_location', function($location) {
$location = 'https://yourdomain.com/' . \RankMath\Helper::get_settings( 'instant_indexing.indexnow_api_key' ) . '.txt'; //change your API Key location
return $location;
} );

44. Filter to change the IndexNow API Key

/**
* Filter to change the API key.
*
* @param string $api_key API key.
*/
add_filter( 'rank_math/instant_indexing/indexnow_key', function($api_key) {
return $api_key;
} );

45. Filter to disable restrictions on updating PRO version before Free version

/**
* Filter to remove restrictions in updating PRO version before the Free version
*/
add_filter( 'rank_math/updates/remove_restrictions', '__return_true' );

46. Filter to disable Rich Text Editor in a specific taxonomy

/**
* Filter to disable Rich Text editor in specific taxonomy.
*
* @param string $disable Whether to disable the Rich Text editor.
* @param string $taxonomy Taxonomy name.
*/
add_filter( 'rank_math/admin/disable_rich_editor', function( $disable, $taxonomy ) {
return true;
}, 10, 2 );

47. Filter to change Local SEO shortcode content

/**
* Filter to change the Local SEO shortcode output.
*
* @param string $html The HTML output of the shortcode.
*/
add_filter('rank_math/contact_info/html', function($html){
return $html;
});

48. Filter to disable rewriting Front base for Locations CPT

/**
* Filter to disable rewriting Front base for Locations CPT.
*/
add_filter( 'rank_math/locations/front', '__return_false' );

49. Filter to remove SEO filters from posts

/**
* Filter to remove SEO Filters from Posts.
*
* @param array $options SEO Filter options.
* @param string $post_type Post type.
*
* @param array/bool Filtered options
*/
add_filter( 'rank_math/manage_posts/seo_filter_options', '__return_false' );

50. Filter to Remove Lock Modified Date option

/**
* Filter to remove the lock modified date option
*/
add_filter( 'rank_math/lock_modified_date', '__return_false' );

51. Filter to Enable Rank Math GTIN Field

/**
* Filter to enable Rank Math GTIN field.
*/
add_filter( 'rank_math/woocommerce/add_gtin_field', '__return_true' );