-
my site has 40k ++ posts, manual bulk editing takes a long time and also not all videos are hosted on youtube.
I’m using this code, but sitemap gets no limit. how to limit the video-sitemap so that it will make their pages 1,2,3 .. following sitemap settings links per sitemap (currently 1000 links per sitemap)?
/* Filter to add links in the new Sitemap.*/ add_action( 'rank_math/sitemap/video_content', function() { $site_title = get_bloginfo('title'); $site_url = get_bloginfo('url'); $postsForSitemap = get_posts( array( 'posts_per_page' => -1, # total 40k++ post 'orderby' => 'modified', 'post_type' => array( 'post' ), 'order' => 'DESC' ) ); if ( str_replace( '+', '', get_option( 'gmt_offset' ) ) < 10 ) { $tempo = '+0' . str_replace( '+', '', get_option( 'gmt_offset' ) ); } else { $tempo = get_option( 'gmt_offset' ); } if( strlen( $tempo ) == 3 ) { $tempo = $tempo . ':00'; } $index = ''; foreach( $postsForSitemap as $post ) { setup_postdata( $post ); $postdate = explode( " ", $post->post_modified ); $get_title = get_the_title($post); $get_url = get_permalink($post); $urlgambar = get_field('series_thumbnail_ex', $post); $get_series = get_field('series_seri', $post); if( !empty( $urlgambar) ) { $getgambar = $urlgambar; } else { $thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id,'', true); $getgambar = $thumb_url[0]; }; $get_video_duration = get_post_meta( $post->ID, 'series_videoembed_duration', true ); $index .= ' <url> <loc>'.$get_url.'</loc> <video:video> <video:title><![CDATA[Nonton Anime '.$get_title.' Sub Indo - '.$site_title.']]></video:title> <video:publication_date>' . $postdate[0] . 'T' . $postdate[1] . $tempo . '</video:publication_date> <video:description><![CDATA[Nonton Anime '.$get_title.' Sub Indo. download streaming resolusi tinggi 720p, 480p, 360p lengkap Full HD Batch Mp4 dan Mkv online gratis]]></video:description> <video:player_loc allow_embed="yes">'.get_embed_url($post->ID).'</video:player_loc> <video:category><![CDATA['.get_the_title($get_series).']]></video:category> <video:thumbnail_loc>'.$getgambar.'</video:thumbnail_loc> <video:duration>'.RankMath\Helper::duration_to_seconds($get_video_duration).'</video:duration> </video:video> </url>'; }; return $index; });
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The ticket ‘How to create video sitemap on the fly ?’ is closed to new replies.