I want to remove Jetpack’s Open Graph meta tags for certain page by page/post ID.
I have tried to add this code to the theme function.php
add_filter( 'jetpack_enable_open_graph', '__return_false' );
It works but for the entire post/page. So, how to make it only applied for a certain post/page ID?
You could try this:
add_filter( 'jetpack_enable_open_graph', 'custom000_jetpack_enable_open_graph', 100, 2 );
function custom000_jetpack_enable_open_graph( $return_false, $int ){
if ( is_page() || is_single() ) {
global $post;
// Array of post IDs where you want it disabled
$ids = array(1, 2, 3, 4, 5, 6);
if( in_array($post->ID, $ids) ){
return false;
}
}
return $return_false;
}