RichSnippet (ImageObject and VideoObject)
-
Hello, I am having the problem that the child post does not have featured image then in schema “ImageObject” will not appear.
Before that I added the code below to display the images shared on social networks
function add_parent_post_image( $manager ) { if ( is_singular( 'life' ) ) { global $post; $manager->add_image_by_id( get_post_thumbnail_id( $post->post_parent ) ); } } add_filter( 'rank_math/opengraph/facebook/add_images', 'add_parent_post_image' ); add_filter( 'rank_math/opengraph/twitter/add_images', 'add_parent_post_image' );
Next problem I add the code below to show the video schema but the “‘inLanguage’ => ‘en-PH’,” section automatically switches to “‘inLanguage’ => ‘en-US'”.
How can I fix it.add_filter( 'rank_math/json_ld', function( $json_ld, $json ) { if ( is_singular() && ! isset( $json_ld['richSnippet'] ) ) { $post_id = $json->post_id; $json_ld['richSnippet'] = [ '@context' => 'https://schema.org', '@type' => 'VideoObject', 'name' => $json->parts['title'], 'description' => $json->parts['desc'], 'uploadDate' => get_post_meta( $post_id, '_meta_key', true ), 'duration' => get_post_meta( $post_id, '_meta_key', true ), 'contentUrl' => get_post_meta( $post_id, '_meta_key', true ), 'embedUrl' => get_post_meta( $post_id, '_meta_key', true ), 'interactionCount' => get_post_meta( $post_id, '_meta_key', true ), 'thumbnailUrl' => get_post_meta( $post_id, '_meta_key', true ), 'inLanguage' => 'en-PH', 'subtitleLanguage' => 'en-US', ]; } return $json_ld; }, 11, 2);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘RichSnippet (ImageObject and VideoObject)’ is closed to new replies.