Skip to main content

Gutenberg

1. Filter to disable Rank Math Integration from the Gutenberg Sidebar

Use this filter to remove Rank Math integration from the Gutenberg Sidebar and add old meta boxes below the content area.

/**
* Disable Gutenberg Sidebar Integration
*/
add_filter( 'rank_math/gutenberg/enabled', '__return_false' );

2. Filter to add meta keys for enqueueing data in the Gutenberg

/**
* Filter to add meta keys for enqueueing data in the Gutenberg
*/
add_filter( 'rank_math/metabox/{$type}/meta_keys', function( $keys ) {
$keys['facebookTitle'] = 'facebook_title';
return $args;
} );

When using this metakey, please prefix it with rank_math_

3. Filter to add metadata for enqueueing for Gutenberg use

/**
* Filter to add metadata for enqueueing for Gutenberg use
*/
add_filter( 'rank_math/metabox/{$type}/values', function( $values, $screen ) {
$object_id = $screen->get_object_id();
$object_type = $screen->get_object_type();
$values['videoSitemap'] = [
'robots' => $screen->get_meta( $object_type, $object_id, 'rank_math_news_sitemap_robots' ),
'genres' => $screen->get_meta( $object_type, $object_id, 'rank_math_news_sitemap_genres' ),
'keywords' => $screen->get_meta( $object_type, $object_id, 'rank_math_news_sitemap_keywords' ),
'stockTickers' => $screen->get_meta( $object_type, $object_id, 'rank_math_news_sitemap_stock_tickers' ),
];
return $values;
} );

$type can be post, term, and user.