Help needed in customizing image sitemap
-
Hi Team ,
we have a used and enabled jetpack sitemap and its is quite helpful but we are having some issue with Page URL values populated into it .
Basically we have custom taxonomy “coupon_store” and these images are used a coupon_store logo image , we upload image and store image id in term meta table of wordpress to know which image id to use for the particular coupon store .
but the page url must have values of the respective coupon store url but its referring to 404 broken links .
This is very urgent for us as more than millions of 404 broken pages are present this way on our site
we tried using this filter but its not executing at all
can u please guide us
the code snippet we used is :
function my_custom_sitemap_image_item( $item_array, $post_id ) { // Get the terms associated with the post for your custom taxonomy. $terms = wp_get_post_terms( $post_id, 'coupon_store' ); // If terms are assigned to the post, modify the sitemap entry. if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) { // Get the first term. $term = array_shift( $terms ); // Get the term link. $term_link = get_term_link( $term, 'coupon_store' ); // If no error occurred, replace the 'loc' element with the term link. if ( ! is_wp_error( $term_link ) ) { $item_array['loc'] = esc_url( $term_link ); } } return $item_array; } // Hook into the image sitemap item filter. add_filter( 'jetpack_sitemap_image_sitemap_item', 'my_custom_sitemap_image_item',9, 2 );
The page I need help with: [log in to see the link]
- The topic ‘Help needed in customizing image sitemap’ is closed to new replies.