• Hi there,

    just wanted to share this real quick and maybe you may want to consider this for future updates.

    I just tried out the plugin and when I looked at the Sitemap I saw that none of the images in my custom-posts had been added. I looked at the code and figured that it was because the function looks at the post-content but my images are added as a gallery via ajax and are only attached to the post through the optional “attached to”-attribute.

    So since I didn’t find a hook to enhance the post-sitemap I just added some code after your image-preg_match_all:

    ‘$media = get_attached_media( “image”, $p->ID );
    foreach ($media as $array => $post_object) {
    $src = $post_object->guid;
    $image = array(“src” => apply_filters( “wpseo_xml_sitemap_img_src”, $src, $p ));
    $image[“title”] = $post_object->post_title;
    $image[“alt”] = $post_object->post_excerpt;
    $image = apply_filters( “wpseo_xml_sitemap_img”, $image, $p );
    $url[“images”][] = $image;}’

    Of course now I have to look out for your updates so my changes won’t get lost!

    Cheers,
    Andreas

    https://www.ads-software.com/plugins/wordpress-seo/

  • The topic ‘Integrate attached media into sitemap’ is closed to new replies.