Issue with Video Sitemap Not Syncing Properly

#978426
  • Resolved Dev 1
    Rank Math free

    Hello,

    We are experiencing an issue with the Rank Math video sitemap, where there seems to be a discrepancy between the videos detected in the database and those displayed in the sitemap. Here’s a breakdown of what we’ve found:
    1. The plugin retrieves video metadata from the database to generate the sitemap.
    2. When generating a sitemap for a post, the system detects 31 videos, but some of them have no content (empty fields).
    3. Running the same query directly in the database returns 31 videos, all with content.
    4. Checking the WordPress post admin panel, only 22 videos appear in the Schema block, which matches those correctly displayed in the sitemap.
    5. However, counting the actual embedded videos in the post results in 17 videos.
    6. This inconsistency suggests that the sitemap errors are caused by outdated or unsynchronized data between the database and Rank Math’s schema detection.
    7. We attempted disabling automatic video detection for posts when generating the schema, but this did not resolve the issue.

    Would you be able to provide guidance on how to resolve this problem?
    Looking forward to your advice.

    Best regards,
    Dmytro

Viewing 9 replies - 31 through 39 (of 39 total)
  • Dev 1
    Rank Math free

    Hey it’s been 2 weeks can you please get back to us ?

    Hello,

    Sorry for the delay in reply.

    The temporary admin login you shared is currently not working. Please re-activate it so we can check the issue further.

    Looking forward to helping you.

    Dev 1
    Rank Math free

    any updates?

    Hello,

    It looks like there are as many video schemas as RankMath outputs, but most of them are empty ( not serialized correctly ).

    For example for these two posts:

    • https://env-evabootcom-experiments.kinsta.cloud/blog/bypass-linkedin-weekly-invitation-limit
    • https://env-evabootcom-experiments.kinsta.cloud/blog/how-to-get-emails-from-linkedin-sales-navigator

    When you run the query:

    
    SELECT * FROM wp_postmeta
    WHERE post_id IN (7023, 8150)
    AND meta_key = 'rank_math_schema_VideoObject'
    LIMIT 400
    

    You get 301 entries, just for the two posts, one with 292 and the other with 9 ( they all appear to have content, but not correctly serialized ).

    If you try to output the schemas for the two posts eg

    
    add_filter( 'the_content', function ( $content ) {
        global $post;
        $schemas = get_post_meta( $post->ID, 'rank_math_schema_VideoObject' );
        return $content;
    });
    

    Some keys of the $schemas have false as value.

    Solutions:
    * Option 1 : Try and regenerate Video Schema, this will delete old entries and regenerate new ones, eliminating the issue you have currently.
    * Option 2 : Delete empty ( incorrectly serialized video schemas ) by running delete_post_meta( $post->ID, 'rank_math_schema_VideoObject', false ); against all posts with video schemas ( you may need to backup your sites before this ).
    * Option 3 : We have temporarily added if ( empty( $schema ) ) continue; after L212 of file seo-by-rank-math-pro/includes/modules/video-sitemap/class-video-provider.php

    We apologize for any inconveniences that might have been caused as a result of this issue.

    Thank you.

    Dev 1
    Rank Math free

    Hello,

    Thanks for the suggestions.

    Regarding Option 1:
    I could not find any tool to regenerate the Video Schema. According to your documentation(https://rankmath.com/kb/add-video-schema-to-existing-posts/), such a tool should exist, but there is nothing available on the website or in the plugin settings. Could you please clarify where exactly it can be accessed?

    Regarding Option 3:
    Simply adding if ( empty( $schema ) ) continue; might hide the problem temporarily, but it doesn’t actually fix the root cause or update the schema data correctly. I could have added such a workaround myself without waiting two months for a solution.

    We need a real fix that regenerates or corrects the corrupted schemas, not just a way to skip over them.

    Please advise on how to properly proceed.

    Thank you.

    Hello,

    For the missing regenarate video schema for old posts feature ( https://rankmath.com/kb/add-video-schema-to-existing-posts/#generate-video-schema-for-old-posts-and-pages ), we re installed RankMath Free plugin and it was fixed.

    Still the regenerate videos schemas was not working, but worked after deleting all entries of rank_math_schema_VideoObject in the postmeta table.

    The video sitemap now shows 2400 entries from 6000+ when we had some empty.

    We couldn’t reproduce this issue and we suspect it was a corrupt import, could you please share the source where you imported the schemas, if any; so we can troubleshoot with that.

    Thank you.

    Dev 1
    Rank Math free

    Hi, I once used code like this to generate a schema

    function find_and_add_video_schema($post_id) {
        $content = get_post_field('post_content', $post_id);
        
        // Поиск iframe с YouTube
        if(preg_match('/<iframe.*src="https?:\/\/(?:www\.)?youtube.com\/embed\/([^"]+)".*><\/iframe>/', $content, $matches)) {
            $video_id = $matches[1];
            
            $video_schema = [
                '@type' => 'VideoObject',
                'name' => get_the_title($post_id),
                'description' => get_the_excerpt($post_id),
                'uploadDate' => get_the_date('c', $post_id),
                'thumbnailUrl' => "https://img.youtube.com/vi/{$video_id}/maxresdefault.jpg",
                'embedUrl' => "https://www.youtube.com/embed/{$video_id}"
            ];
              
            update_post_meta($post_id, 'rank_math_schema_VideoObject', $video_schema);
        }
    }
    add_action('save_post', 'find_and_add_video_schema');
    Dev 1
    Rank Math free

    did you see this message?
    I sent it a week ago.
    Hi, I once used code like this to generate a schema

    function find_and_add_video_schema($post_id) {
    $content = get_post_field(‘post_content’, $post_id);

    // Поиск iframe с YouTube
    if(preg_match(‘/<iframe.*src=”https?:\/\/(?:www\.)?youtube.com\/embed\/([^”]+)”.*><\/iframe>/’, $content, $matches)) {
    $video_id = $matches[1];

    $video_schema = [
    ‘@type’ => ‘VideoObject’,
    ‘name’ => get_the_title($post_id),
    ‘description’ => get_the_excerpt($post_id),
    ‘uploadDate’ => get_the_date(‘c’, $post_id),
    ‘thumbnailUrl’ => “https://img.youtube.com/vi/{$video_id}/maxresdefault.jpg”,
    ’embedUrl’ => “https://www.youtube.com/embed/{$video_id}”
    ];

    update_post_meta($post_id, ‘rank_math_schema_VideoObject’, $video_schema);
    }
    }
    add_action(‘save_post’, ‘find_and_add_video_schema’);

    Hello,

    That could be the cause of the issue as the video schema is incomplete ( missing some properties ).
    Below is what is expected of the schema ( properties ).

    
    [
    				'@type'            => 'VideoObject',
    				'metadata'         => [
    					'title'                   => 'Video',
    					'type'                    => 'template',
    					'shortcode'               => uniqid( 's-' ),
    					'isPrimary'               => empty( DB::get_schemas( $this->post->ID ) ),
    					'reviewLocationShortcode' => '[rank_math_rich_snippet]',
    					'category'                => '%categories%',
    					'tags'                    => '%tags%',
    					'isAutoGenerated'         => true,
    				],
    				'name'             => '%seo_title%',
    				'description'      =>  '%seo_description%',
    				'thumbnailUrl'     =>  '%post_thumbnail%',
    				'embedUrl'         => '',
    				'contentUrl'       => '',
    				'duration'         => '',
    				'width'            =>  '',
    				'height'           =>  '',
    				'isFamilyFriendly' => ''
    			]
    

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 9 replies - 31 through 39 (of 39 total)

The ticket ‘Issue with Video Sitemap Not Syncing Properly’ is closed to new replies.