Custom fields to image sitemap: only works if gallery is added to standard block
-
Hi,
I have added the code from here to my functions.php (for testing purposes I am using the theme Twenty Twenty-One). I add galleries via the Advanced Custom Fields WYSIWYG editor and would like the images to be indexed.
However, it only works when there is an image or gallery in one of the standard blocks. Is this normal behaviour or have I missed something in the implementation? (Apologies if I have!)
Also, I have a question regarding the structure of the sitemap. At the moment it looks like this for a post with a gallery (first image added in WP block in order to get the output):
<url> <loc>xxx/2021/01/03/test-3-acf-gallery/</loc> <lastmod>2021-01-04T18:50:23+00:00</lastmod> <image:image> <image:loc><![CDATA[xxx/wp-content/uploads/2020/12/IMG_2615-843x1024.jpg]]></image:loc> </image:image> <image:image> <image:loc><![CDATA[<div id='gallery-1' class='gallery galleryid-58 gallery-columns-3 gallery-size-thumbnail'> <figure class='gallery-item'> <div class='gallery-icon landscape'> <a href='xxx/gallery/img_2143/'><img width="150" height="150" src="xxx/wp-content/uploads/2020/12/IMG_2143-150x150.jpg" class="attachment-thumbnail size-thumbnail" alt="test" loading="lazy" style="width:100%;height:68.35%;max-width:2000px;" /></a> </div> </figure> <figure class='gallery-item'> <div class='gallery-icon landscape'> <a href='xxx/gallery/img_2582/'><img width="150" height="150" src="xxx/wp-content/uploads/2020/12/IMG_2582-150x150.jpg" class="attachment-thumbnail size-thumbnail" alt="test" loading="lazy" style="width:100%;height:83.7%;max-width:2000px;" /></a> </div> </figure> </div> ]]></image:loc> </image:image> </url>
Is this structure correct? I am not very familiar with SEO best practices but a brief look at the Google guidelines suggests that each image should be processed like this:
<image:image> <image:loc>http://example.com/image.jpg</image:loc> </image:image>
When I add a gallery via a Gutenberg block, that’s the structure I see in the sitemap.
Many thanks in advance for any help
- The topic ‘Custom fields to image sitemap: only works if gallery is added to standard block’ is closed to new replies.