Epic 404 on listings

This topic contains 28 replies, has 3 voices, and was last updated by  Stiofan O’Connor 6 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #388623

    patripat
    Expired Member
    Post count: 165
    This reply has been marked as private.
    #388715

    patripat
    Expired Member
    Post count: 165

    Hi Paolo,

    have you had a chance to have a look please?

    Best regards,
    Pat

    #388725

    Stiofan O’Connor
    Site Admin
    Post count: 22956
    This reply has been marked as private.
    #388727

    patripat
    Expired Member
    Post count: 165

    Hi Stiofan,

    Thanks for resolving the country thingy

    i enabled category in url but then google still gives them without the category in it…

    maybe i need to do a 301 redirect (how?)? or do you have a more permanent idea? i need to get that fixed even if i switch to default country, selected regions and selected cities?

    What do you think?
    Pat

    #388731

    Paolo
    Site Admin
    Post count: 31206

    The 2 that weren’t working yesterday are working now:

    https://www.toutwaterloo.be/listing/belgium/wallonie/lasne/restaurants/kaiyou-restaurant-1/

    https://www.toutwaterloo.be/listing/belgium/wallonie/waterloo/menunextdoor/claudia-nathalie-1/

    It’s possible that you added listings after changing permalink structure and Google Indexed them with that structure. In that case it’ll be very difficult to write a script to redirect them all correctly.

    That’s why the permalink structure should be set before allowing Google to scrape your pages.

    Can you gather a list of the listing that are not working now?

    Let us know,

    #388732

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    “i enabled category in url but then google still gives them without the category in it”

    The ones i checked from this search https://wpgeodirectory.com/support/topic/epic-404-on-listings/#post-388616

    Now work, so i gess google has a mix and mash of some with and some without, just pick one and stick with it.

    Check if there are many links google has to broken urls, you might have to do some redirects.

    Stiofan

    #388734

    patripat
    Expired Member
    Post count: 165

    yes and yes, in fact i did all in the same time, thinking that google would crawl again if i change something but it does not seem to happen

    now do i have to provide a new sitemap or something?

    if a redirect is needed how do i do that?

    is there a way to validate all places as working links without browsing 3600 url’s?

    Thanks for your help,
    Pat

    #388793

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    if it were me..

    I would write a wee snippet that only ran on the 404 page, it would grab the last slug and check if its a real post and if so redirect to the proper url.

    Stiofan

    #388794

    patripat
    Expired Member
    Post count: 165

    Hi Stiofan,

    how would this code be looking please?

    Thanks,
    Pat

    #388805

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Pat,

    
    
    function _my_fix_listings_404s(){
    	if( is_404() ){
    
    		$url = $_SERVER['REQUEST_URI'];
    		$slug = basename($url);
    		global $wpdb;
    		$post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type IN ('gd_place','gd_event') AND post_status = 'publish' AND post_name = %s", $slug));
    
    		if(!empty($post_id)){
    			wp_safe_redirect( esc_url( get_permalink( $post_id) ), 301 );
    			exit;
    		}
    	}
    }
    add_action( 'template_redirect', '_my_fix_listings_404s' );

    Stiofan

    #388808

    patripat
    Expired Member
    Post count: 165
    This reply has been marked as private.
    #388812

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    I updated my code here and also on your site.

    In this case its not working because its looking for “mixto-restaurant” but the actual url is “mixto-restaurant-1”

    If this is wide spread we could try altering the query a bit but if its just that listing then its not really worth it.

    Stiofan

    #388814

    patripat
    Expired Member
    Post count: 165

    Shall we leave it like this for 24-48hrs to see how it goes?

    #388821

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    yeah give it a try.

    Stiofan

Viewing 14 posts - 16 through 29 (of 29 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket