Filter wpseo_sitemap_urlimages is not triggered on Woo product archive pages
- [x] I've read and understood the contribution guidelines.
- [x] I've searched for any related issues and avoided creating a duplicate issue.
Please give us a description of what happened
In a web shop the product category pages are very important focus pages for SEO. I’d like to add some images to their Yoast generated XML sitemap which are not picked up automatically by the Yoast SEO plugin. I do this successfully on posts using the wpseo_sitemap_urlimages filter. However, I noticed that this filter is not triggered on the Woocommerce product category pages.
I noticed that this filter is not triggered on the Woocommerce product category pages. So Yoast is not activating this trigger on a product category page. So my code is never called upon.
Also see: [https://wordpress.org/support/topic/filter-wpseo_sitemap_urlimages-is-not-triggered-on-woo-product-archive-pages/#post-16520945]
To Reproduce
Step-by-step reproduction instructions
- Add filter (see code snippet as example below)
- Regenerate sitemap
- Check sitemap and see if image has been added to the sitemap: it is not!
Expected results
- Expected to see image added to sitemap
Actual results
- Image is not added to the sitemap
Screenshots, screen recording, code snippet
If possible, please provide a screenshot, a screen recording or a code snippet which demonstrates the bug.
Code snippet example:
/* Add additional product images to product category Yoast sitemap / function add_additional_images_product_category_sitemap( $images, $post_id ) { if ( is_product_category() ) { / Just add a test image */ $image_url = "https://my-site-location-of-the-image/sample.jpg"; array_push($images, ['src' => $image_url, 'title' => get_the_title( $post_id )]); }; return $images; };
add_filter( 'wpseo_sitemap_urlimages', 'add_additional_images_product_category_sitemap', 10, 2 );
Technical info
- If relevant, which editor is affected (or editors):
- [ ] Block Editor
- [ ] Gutenberg Editor
- [ ] Elementor Editor
- [ ] Classic Editor
- [ ] Other:
- Which browser is affected (or browsers):
- [ ] Chrome
- [ ] Firefox
- [ ] Safari
- [ ] Other:
Used versions
- Device you are using:
- Operating system:
- PHP version: 8.0.27
- WordPress version: 6.1.1
- WordPress Theme: GeneratePress with GP Premium 2.2.2
- Yoast SEO version: 20.1
- Gutenberg plugin version:
- Elementor plugin version:
- Classic Editor plugin version:
- Relevant plugins in case of a bug:
- WooCommerce version: 7.4.0
Duplicate of #19098.