-
Dear Rank Math Support Team,
I’m writing to you with a request for assistance regarding the use of the filters provided in the “Rank Math SEO Filters and Hooks for Developers” blog post.
Issue with the Link Suggestion Metabox filter: I’ve tried to use the following filter to enable/disable the Link Suggestion Metabox for a specific post type, but it’s not working as expected:
add_filter( 'rank_math/settings/titles/link_suggestions', function( $default, $post_type ) {
return 'off';
}, 10, 2 );The Link Suggestion Metabox is still being displayed when I edit or create a new post, despite using this filter.
Issue with the SEO Metabox filter: I’ve tried to use the following filter to show/hide the SEO Metabox:
add_filter( 'rank_math/metabox/add_seo_metabox', function( $default ) {
return 'off';
});This code also does not work, as the SEO Metabox is still being displayed when I edit or create a post. However, I found that the following code does work to remove the SEO Metabox:
add_filter( 'rank_math/metabox/add_seo_metabox', '__return_false');But I’m unable to find a way to apply this filter to only specific post types.
Attempted solution for post-type-specific SEO Metabox filtering: I’ve tried the following code to disable the SEO Metabox for a specific post type (in this case, ‘custom_templates’):
function rank_math_setup_disable_metabox() {
// Check if we are on the post editing screen and the post ID is set
if (isset($_GET['post'])) {
$post_id = $_GET['post'];
$post = get_post($post_id);
$post_type = get_post_type($post);// Checking post type here
if ($post_type === 'custom_templates') {
add_filter('rank_math/metabox/add_seo_metabox', '__return_false');
}
} elseif (isset($_GET['post_type']) && $_GET['post_type'] === 'custom_templates') {
// This is for handling new post creation of specific post type
add_filter('rank_math/metabox/add_seo_metabox', '__return_false');
}
}// Hook this function into admin_init
add_action('admin_init', 'rank_math_setup_disable_metabox');However, the SEO Metabox is still being displayed, even for the ‘custom_templates’ post type.
I would greatly appreciate it if you could provide some guidance on how to properly use the filters mentioned in the “Rank Math SEO Filters and Hooks for Developers” blog post to achieve the desired functionality. Any assistance you can offer would be tremendously helpful.
Thank you for your time and attention.
The ticket ‘Filters for Link Suggestion Metabox and SEO Metabox not working’ is closed to new replies.