tkdanimal
Forum Replies Created
-
I had been very unsuccessful using that filter. I didn’t mess around with it too much since I found this other solution that worked fine. But I am going to put it here since it may be useful for others.
// define the wpseo_sitemap_urlimages callback function filter_wpseo_sitemap_urlimages( $images, $post_id ) { // make filter magic happen here... return $images; }; // add the filter add_filter( 'wpseo_sitemap_urlimages', 'filter_wpseo_sitemap_urlimages', 10, 2 );So i figured it out and i thought I would post my solution here because it is very hard to find info on making Yoast hooks.
I found this really good snippet by this dude online and modified it a bit so that it works with multiple images.
function wpseo_xmlsitemap_add_attached_images( $images, $post_id ) { sophisticated cases like query_var usage $attached_images = get_attached_media( 'image', $post_id); if($attached_images){ foreach($attached_images as $attached_image){ $image_arr = array(); $image_arr['src'] = $attached_image->guid; $images[] = $image_arr; } return $images; } }; add_filter( 'wpseo_sitemap_urlimages', 'wpseo_xmlsitemap_add_attached_images', 10, 2 );I see how what I said could be confusing. sorry for the miss communication. no matter what I do I cannot get the image counter to populate.
i am adding the images in the WordPress cms with meta fields created by Advanced Custom Fields PRO, and then rendering them out with my timber template. I will try disabling all the plugins and see what effect it has.
my issue is that the images appear in the site map when media and attachment URL is set to no, but they never show up in the image total in the XML map.
this can be seen all over the website as none of the images are showing up, but a good example is this regal project.
https://staging.fivestonestudios.com/work/regal-3d-animation-cinematic-trailer/
https://staging.fivestonestudios.com/works-sitemap.xmlthis is with media / attachment URL set to yes.