Home › Forums › Gillion Theme › None of the images on my homepage and several other pages appear in the sitemap
Home › Forums › Gillion Theme › None of the images on my homepage and several other pages appear in the sitemap
I looked through my sitemap and noticed that whenever I use wpbakery as content block on any of my pages, none of the images inside WP Bakery block appear in the sitemap generated by Yoast.
This results in a negative impact on our Google ranking SEO due to thin pages. Thus we really need Yoast team help to debug the issue.
You can see the example even on my homepage: https://dailyspin.id/
Where the image count on Yoast sitemap is 0: https://snipboard.io/X4r2Mp.jpg
You can see that actually I had so many other images here: https://snipboard.io/PaUeb2.jpg
<hr />
I already reported this to Yoast and they asked me to do this:
Some plugins, themes and page builder modules may not show additional images in the sitemap, if your products have additional images you want included you may need to add them via a filter:
wpseo_sitemap_urlimages
.
Though I’m not sure how to implement such thing in Gillion theme. I saw other themes work with something like this: https://gist.github.com/chriswiggins/0756f61f745b9b08cc13e86573768f05.
Please help, thank you
Hi @vickwinata,
I hope you are well today and thank you for your question.
You can just add the below code in the functions.php file of the Gllion child theme that you are using on your website.
/* Add impreza images to Yoast sitemap, since Yoast doesn't read impreza's Page * Builder code - borrowed from (https://github.com/Yoast/wordpress-seo/issues/4808) */ function impreza_filter_wpseo_sitemap_urlimages($images, $post_id) { $post = get_post($post_id); if (is_object($post)) { $content = $post->post_content; # Parse impreza Image modules preg_match_all("/image=\"(\d+)\"/", $content, $impreza_images); if(count($impreza_images) < 2){ return $images; } foreach ($impreza_images[1] as $impreza_image_id) { $attachment = wp_prepare_attachment_for_js( $impreza_image_id ); $images[] = array( 'src' => $attachment["url"], 'title' => $attachment["title"], 'alt' => $attachment["description"] ); } } return $images; } add_filter('wpseo_sitemap_urlimages', 'impreza_filter_wpseo_sitemap_urlimages', 10, 2);
Best regards,
Shufflehound team
If that code does not work then please try using the below code.
https://github.com/Yoast/wordpress-seo/issues/11560#issuecomment-438616593
Do I just need to change anything with “Impreza” here with “Gillion“? Please advise
<pre>/* Add impreza images to Yoast sitemap, since Yoast doesn't read impreza's Page
* Builder code - borrowed from (https://github.com/Yoast/wordpress-seo/issues/4808) */
function impreza_filter_wpseo_sitemap_urlimages($images, $post_id)
{
$post = get_post($post_id);
if (is_object($post)) {
$content = $post->post_content;
# Parse impreza Image modules
preg_match_all("/image=\"(\d+)\"/", $content, $impreza_images);
if(count($impreza_images) < 2){
return $images;
}
foreach ($impreza_images[1] as $impreza_image_id)
{
$attachment = wp_prepare_attachment_for_js( $impreza_image_id );
$images[] = array(
'src' => $attachment["url"],
'title' => $attachment["title"],
'alt' => $attachment["description"]
);
}
}
return $images;
}
add_filter('wpseo_sitemap_urlimages', 'impreza_filter_wpseo_sitemap_urlimages', 10, 2);</pre>
<pre>
No, you don’t need to change the name.
Oh the thing is I’m not using Impreza theme but Gillion theme with WP Bakery as my page builder.
As said earlier, please do not change anything.
Ok let me try first
Ok
I’ve done it but there’s no impact on my sitemap, it still doesn’t contain any image
Then please contact the Yoast plugin support to make it work.