• Resolved askmeoffers

    (@askmeoffers)


    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]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there, @askmeoffers,

    Apologies for the delay in getting back to you, especially as you mentioned the matter was quite urgent (and I do see why).

    It seems like you disabled the Jetpack sitemap feature, and the sitemap you linked returns a 404 page now.

    Do you still need with that or did you figure something else out to address your request?

    Thread Starter askmeoffers

    (@askmeoffers)

    Hi Team ,

    We still need help on this .

    I went ahead and have enabled the sitemap as its 404 for millions of urls so had disabled , request your support on this

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there, @askmeoffers,

    Fo starters, the site is incredibly slow to load on my end. There might be something that is slowing it down so much, and that might also affect the sitemap and the rest of your site. I’d recommend reaching out to your host to sort that out.

    I then checked the image sitemaps, and even though it took a good couple of minutes to load, it loaded, and I couldn’t see any 404 pages.

    I then tried to load the main sitemap, and I got a 503 error – that’s typical of server errors happening, as suspected.

    I finally checked the Jetpack connection, and I can some errors related to the low speed of the site, and some blocks happening on the server’s end that’s preventing Jetpack from working as expected.

    I’d suggest to have these fixed, so Jetpack can connect properly, and we can inspect the sitemaps.

    Thread Starter askmeoffers

    (@askmeoffers)

    Sorry for the inconvenience caused , due to server maintainaince,

    Jetpack is enabled too with sitemap feature also ON .

    Currently I am unable to see any entries for sitemap earlier it use to be there , I had updated the version of the jectpack just now .

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there, @askmeoffers,

    Unfortunately, I still can see 503 errors when debugging Jetpack, meaning the connection is still broken. The error I see also says the following, just in case you want to pass the info again to your host:

    The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later

    We cannot proceed with our investigation until Jetpack is well connected. The sitemaps I am trying to see are loading and never display, which make me think they’re being affected by the same problem as Jetpack.

    Let us know when you manage to fix this! ??

    Thread Starter askmeoffers

    (@askmeoffers)

    Hi Stef,

    Sorry again for the inconvenience caused, we have now raised the issue with host to fix it and its has been resloved by migrating to different server , you may check the issue now basically the “page url” values are wrong and are 404, is there any hook or snippet which we can use to correct them.

    Thread Starter askmeoffers

    (@askmeoffers)

    Hi Team,

    Any findings on the issue ?

    Please help us / guide us with your valuable expertise so that we can get rid of 404 links .

    Basically “Page URL” values as 404 , and we want to add custom filter/code to replace 404 with actual url where this image is attached .

    basically they are present on WordPress custom taxonomy “coupon_store”.

    Please guide us with your valuable inputs .

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there, askmeoffers,

    Thanks for the follow-up, I see that now Jetpack is well connected to your site.

    I’m going to escalate this to our developers, as I didn’t find anything helpful in our internal documentation. To make sure I’m not missing anything out while reportin this to our tech team, here’s a recap:

    • you created an image sitemap for your store via Jetpack
    • some URLs are retuning a 404 error
    • you pinpointed the pages with this issue being pages with the custom taxonomy “coupon_store”
    • the custom taxonomy has a specific goal to let you choose the image to tie with the coupon
    • you tried adding a code snippet to rectify the 404 errors, with no success
    • you’re therefore asking if there’s anything we can do at our end to fix all these URLs with the 404 errors

    Can you confirm this is correct? Can you also share a small list of links with the 404 error? I didn’t find it easy to get from your sitemap.

    Look forward to your reply, and thanks for your cooperation in sorting that out with us!

    Thread Starter askmeoffers

    (@askmeoffers)

    Hi Team ,

    Thank you for your kind response .

    Let me explain this

    the image site map consists of below fields

    1. #

    2) Page URL

    3) Image URL

    4) Last Modified

    5) Thumbnail

    All the values of (2 Page URL ) are wrong or 404 , i dont know how it is working sometimes it is something and sometimes it is somethign else but values are wrong , lets see as example the 1st entry it pointing to some /news/ which is wrong it should point to /loveinfaith-coupons/ from our domain . how to customize this entry for #2

    so instead of point to https://askmeoffers.com/loveinfaith-coupons/ its pointing to https://askmeoffers.com/news/

    so this happens for all urls we have which are custom taxonomy “coupon_store” where image is actually present as logo image

    • This reply was modified 8 months, 3 weeks ago by askmeoffers.
    • This reply was modified 8 months, 3 weeks ago by askmeoffers.
    • This reply was modified 8 months, 3 weeks ago by askmeoffers.
    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there @askmeoffers,

    Thanks for the example, that clarifies things for me. I just landed on https://askmeoffers.com/loveinfaith-coupons/ and I can’t figure out if it’s a custom post type kind of content.

    If that’s so, I wonder if this code snippet can help, as it includes CPT in the sitemaps. There is a bit more context on this page.

    Can you also tell me if the URLs that work at the moment include images served by your CDN? I can see that the ones erroring are served by your CDN, and I would like to exclude this as potential root of the issue.

    Thread Starter askmeoffers

    (@askmeoffers)

    Hi ,

    Its not a custom post type is a custom taxonomy “coupon_store”

    Also as i mentioned (2 Page URL ) values are wrong or 404 .

    Kindly share this thread with developemnt team they will easily understand

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hey there, @askmeoffers,

    I spoke with our developers, and it seems like the issue is out of our support scope. However, we do have some info to share that can help you figure this out ??

    Here is how image sitemap entries are built in Jetpack:

    
            $parent_url = get_permalink( get_post( $post->post_parent ) );
            if ( '' == $parent_url ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- WPCS: loose comparison ok.
                $parent_url = get_permalink( $post );
            }
    
            $item_array = array(
                'url' => array(
                    'loc'         => $parent_url,
                    'lastmod'     => jp_sitemap_datetime( $post->post_modified_gmt ),
                    'image:image' => array(
                        'image:loc' => $url,
                    ),
                ),
            );

    The structure of the array is a?url, including an array with?loc?,?lastmod, and an?image:image?array including?image:loc . You’re using the?jetpack_sitemap_image_sitemap_itemto modify?loc, which makes sense, and you’re overwriting?loc?with a custom value saved on their end, when it exists.

    The trouble for our developers to fully understand what’s happening at your end is that even if you tried to explain how that custom value is stored, we don’t see the code so there is not much we can do to investigate here.

    That said, there may be one thing worth looking into: you’re trying to get the custom?coupon_store?they stored for that post.
    In this scenario (within the?jetpack_sitemap_image_sitemap_item?filter), the post is the image. Maybe you’re not storing that custom value for each image, maybe you’re storing it for each parent post which contains the image. We can’t tell that for sure because we can’t see the code, but you can figure it out.

    If that’s the case, then in your code snippet, you should try first to get the parent post of the?$post_id?returned by the filter, and then get the?coupon_store?value for that parent post.

    Keep in mind that these are recommendations based on the little knowledge we can get from this thread.
    Since this is something built with your custom code, you need to debug this and figure it out; one option would be to check what the returned values are when you fetch the terms and before trying to display them in the sitemap.

    That’s the best we can do on this matter, and I hope it helps!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Help needed in customizing image sitemap’ is closed to new replies.