Add Translated Version Sitemap Entries for a Specific Term

add_filter( “aioseo_sitemap_term”, “aioseo_filter_sitemap_term”, 10, 2 ); function aioseo_filter_sitemap_term( $entry, $termId ) { if ( 12 === $termId) { // Set the language code for the main URL. $entry[‘language’] = ‘en_US’ // Add the translated versions (language code + URL). $entry[‘languages’]…Continue reading

Change Time zone Offset in the Publish Date of the Sitemap Entries

add_filter( ‘aioseo_sitemap_rss’, ‘aioseo_filter_rss_sitemap_entries’ ); function aioseo_filter_rss_sitemap_entries( $entries ) { $entries = array_map( function ( $entry ) { if ( empty( $entry[‘pubDate’] ) ) { return $entry; } $dateTime = new DateTime(); $dateTime->setTimestamp( strtotime( $entry[‘pubDate’] ) ); $dateTime->setTimezone( new DateTimeZone( ‘Europe/Moscow’…Continue reading

Add Translated Version Sitemap Entries for a Specific Post

add_filter( “aioseo_sitemap_post”, “aioseo_filter_sitemap_post”, 10, 2 ); function aioseo_filter_sitemap_post( $entry, $postId ) { if ( 10 === $postId ) { // Set the language code for the main URL. $entry[‘language’] = ‘en_US’ // Add the translated versions (language code + URL).…Continue reading

Add Additional Custom Sitemap Index

add_filter( ‘aioseo_sitemap_indexes’, ‘aioseo_add_sitemap_index’ ); function aioseo_add_sitemap_index( $indexes ) { $indexes[] = [ ‘loc’ => ‘https://somedomain.com/custom-sitemap.xml’, ‘lastmod’ => aioseo()->helpers->dateTimeToIso8601( ‘2021-09-08 12:02’ ), ‘count’ => 1000 ]; return $indexes; }Continue reading

Add Image to Sitemap From an Image ACF Field

add_filter( ‘aioseo_sitemap_images’, ‘aioseo_filter_sitemap_images’, 10, 2 ); function aioseo_filter_sitemap_images( $images, $post ) { if ( ! function_exists( ‘get_field’ ) ) { return $images; } $customImage = get_field( ‘custom_image’, $post->ID ); if ( ! empty( $customImage ) ) { $images[] = wp_get_attachment_image_url(…Continue reading

Exclude a Specific Term from the Sitemap

add_filter( ‘aioseo_sitemap_exclude_terms’, ‘aioseo_sitemap_filter_excluded_terms’, 10, 2 ); function aioseo_sitemap_filter_excluded_terms( $ids, $type ) { if ( ‘general’ === $type ) { $ids[] = 412; } return $ids; }Continue reading

Exclude a Specific Post from the Sitemap

add_filter( ‘aioseo_sitemap_exclude_posts’, ‘aioseo_sitemap_filter_excluded_posts’, 10, 2 ); function aioseo_sitemap_filter_excluded_posts( $ids, $type ) { if ( ‘general’ === $type ) { $ids[] = 614; } return $ids; }Continue reading

Append a Page to the Additional Pages Sitemap

add_filter( ‘aioseo_sitemap_additional_pages’, ‘aioseo_sitemap_add_additional_pages’ ); function aioseo_sitemap_add_additional_pages( $pages ) { $pages[] = [ ‘loc’ => ‘https://example.com/additional-page’, ‘lastmod’ => ‘2020-12-11 11:11’, ‘changefreq’ => ‘always’, ‘priority’ => (float) 1.0 ]; return $pages; }Continue reading