Problem with Page not found error
-
Hi,
I’ve been trying to fix this problem for a week now and I can’t figure it out. I’ve a property website that was working fine up until 2 weeks ago and I’m getting a page not found error and I can’t figure it out.
I’ve tried installing a back up from a month ago
I’ve tried saving the permalinks again
I’ve changed the permissions on the htaccess
Changed theme and disabled all plugins
and still cant’t figure it outThe page that doesn’t show up isn’t a page as such but rather lists properties that are using the attributes “forsale”
Any help or advice would be great !
-
This topic was modified 4 years, 10 months ago by
Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
The page I need help with: [log in to see the link]
-
This topic was modified 4 years, 10 months ago by
-
You have a 404 error on the entire site, correct ?
https://casafinders.es/You’ll need to go through the permission docs :
or ask tech support with your host.
Hi there @pauldeasy. There could be a small number of things wrong.I can troubleshoot with you? Let us start with what changed 2 weeks ago? Anything you changed or added on the control panel/hosting? Any updates you did?
Hi @corrinarusso thank you for the reply, I actually had a problem over the weekend and the site was completely suspended for going over the cpu limit. It is back up now but I haven’t been able to figure it out
https://casafinders.es/forsale/
https://casafinders.es/forrentand all the subheadings, the subitems on the menu bar.
hi @godseseun444 , thanks for the reply,
The only thing I did was update some plugins, the woocommerce database needed to be updated too. I have since installed a back up from a month ago but the problem still persists.
I’ve done all the usual things of deactivating all plugins and changing the theme, resaved the permalinks but that didn’t work.
https://casafinders.es/forsale/
https://casafinders.es/forrent//forsale/ and /forrent/ don’t seem to exist. If I click on “For Sale” on the menu bar all the subheadings don’t work either.
I can’t find anything with the slug “forsale” or “forrent” on my wordpress dashboard. I used a string locator and found them in CSS, taxonomy.php and functions.php and 1 custom.php. I had some custom work done when I was setting it up originally so these pages I’m having trouble with now would work. I’ve included it here just in case there’s something wrong in it, to be honest I can’t make much sense of it !
.
Custom work done om the functions.phpadd_action( 'init', 'wpse26388_rewrites_init_sale' ); function wpse26388_rewrites_init_sale(){ add_rewrite_rule( 'forsale/page/?([0-9]{1,})/?$', 'index.php?pagename=forsale&paged=$matches[1]', 'top' ); add_rewrite_rule( 'forsale/([^A-Z]+)/page/?([0-9]{1,})/?$', 'index.php?pagename=forsale&property_type=$matches[1]&paged=$matches[2]', 'top' ); add_rewrite_rule( 'forsale/([^A-Z]+)/?$', 'index.php?pagename=forsale&property_type=$matches[1]', 'top' ); } add_action( 'init', 'wpse2638_rewrites_init_rent' ); function wpse2638_rewrites_init_rent(){ add_rewrite_rule( 'forrent/page/?([0-9]{1,})/?$', 'index.php?pagename=forrent&paged=$matches[1]', 'top' ); add_rewrite_rule( 'forrent/([^A-Z]+)/page/?([0-9]{1,})/?$', 'index.php?pagename=forrent&property_type=$matches[1]&paged=$matches[2]', 'top' ); add_rewrite_rule( 'forrent/([^A-Z]+)/?$', 'index.php?pagename=forrent&property_type=$matches[1]', 'top' ); }
and then sort-listing-custom.php
<?php $lastSlug = get_query_var('property_type'); $slug = get_post_field( 'post_name'); $fixslug = ''; switch ($slug) { case 'forsale': $fixslug = 'for-sale'; break; case 'forrent': $fixslug = 'for-rent'; break; default: $fixslug = ''; break; } ?> <div class="property-sort"> <div class="sort-title"> <span class="sort-by"><?php _e( 'Sort By: ', 'realexpert' ); ?></span> <?php $sortby=''; if($fixslug == ""){ $all = 'current'; }else{ $all = ''; $current = ''; } if(isset($_GET['view'])){ $view = '&view='.$_GET['view']; }else{ $view = ''; } $terms = get_terms( 'property-status' ); if(isset($_GET['type']) && $_GET['type'] != ''){ $type = $_GET['type']; }else{ $type = 'all'; } echo '<a href="'.get_site_url().'/properties">'.__( 'All', 'realexpert' ).'</a>'; foreach( $terms as $term ){ $linkSlug = ''; if($fixslug == $term->slug){ $current = 'current'; }else{ $current = ''; } switch ($term->slug) { case 'for-rent': $linkSlug = 'forrent'; break; case 'for-sale': $linkSlug = 'forsale'; break; default: $linkSlug = $term->slug; break; } echo '<a class="'.$current.'" href="'.get_site_url().'/'.$linkSlug.'/'.$lastSlug.'">'.$term->name.'</a>'; } ?> </div> <div class="grid-view hidden-phone"> <?php if((isset($_GET['type']) && $_GET['type'] != 'all') || (isset($_GET['sortby']) && $_GET['sortby'] != 'all') ){ $view = '?type='.$_GET['type'].'&sortby='.$_GET['sortby']; }else{ $view = '?'; } ?> <a href="<?php echo get_permalink().$view.'&view=list'; ?>"><img src="<?php echo get_template_directory_uri().'/images/view-list.png'; ?>" /></a> <a href="<?php echo get_permalink().$view.'&view=grid'; ?>"><img src="<?php echo get_template_directory_uri().'/images/view-grid.png'; ?>" /></a> </div> </div>
Hopefully it’s something simple that I missed.
Thanks againI’m not sure why you have this custom code implemented – the theme sorts the properties based on Sale or Rent status right out of the box :
https://themeforest.net/item/real-expert-responsive-real-estate-and-property-listing-wp-theme/6131977The reason there are no properties found under For Rent is bc all the properties are tagged with For Sale – except for one :
https://casafinders.es/forrent/?type=all&sortby=for-rentYou page is forrent and forsale, however your slug for the posts is for-rent and for-sale
Thank you @pauldeasy. I see where the issue is. It’s when the code calls the property listing category “All” when the URL lands on
https://casafinders.es/forsale/
or https://casafinders.es/forrent/ so it shows no properties found.Yet when you click on the “All” category it does display the properties.
So I have an idea, unfortunatly only you can test it. This piece you sent me, I made a small change which I will show you here. Copy this code and paste it over the code in sort-listing-custom.php. Make sure to only replace the code you showed here from that file with this code and click save.
<?php $lastSlug = get_query_var('property_type'); $slug = get_post_field( 'post_name'); $fixslug = ''; switch ($slug) { case 'forsale': $fixslug = 'for-sale'; break; case 'forrent': $fixslug = 'for-rent'; break; default: $fixslug = ''; break; } ?> <div class="property-sort"> <div class="sort-title"> <span class="sort-by"><?php _e( 'Sort By: ', 'realexpert' ); ?></span> <?php $sortby=''; if($fixslug == ''){ $all = 'current'; }else{ $all = ''; $current = ''; } if(isset($_GET['view'])){ $view = '&view='.$_GET['view']; }else{ $view = ''; } $terms = get_terms( 'property-status' ); if(isset($_GET['type']) && $_GET['type'] != ''){ $type = $_GET['type']; }else{ $type = 'all'; } echo '<a href="'.get_site_url().'/properties">'.__( 'All', 'realexpert' ).'</a>'; foreach( $terms as $term ){ $linkSlug = ''; if($fixslug == $term->slug){ $current = 'current'; }else{ $current = ''; } switch ($term->slug) { case 'for-rent': $linkSlug = 'forrent'; break; case 'for-sale': $linkSlug = 'forsale'; break; default: $linkSlug = $term->slug; break; } echo '<a class="'.$current.'" href="'.get_site_url().'/'.$linkSlug.'/'.$lastSlug.'">'.$term->name.'</a>'; } ?> </div> <div class="grid-view hidden-phone"> <?php if((isset($_GET['type']) && $_GET['type'] != 'all') || (isset($_GET['sortby']) && $_GET['sortby'] != 'all') ){ $view = '?type='.$_GET['type'].'&sortby='.$_GET['sortby']; }else{ $view = '?'; } ?> <a href="<?php echo get_permalink().$view.'&view=list'; ?>"><img src="<?php echo get_template_directory_uri().'/images/view-list.png'; ?>" /></a> <a href="<?php echo get_permalink().$view.'&view=grid'; ?>"><img src="<?php echo get_template_directory_uri().'/images/view-grid.png'; ?>" /></a> </div> </div>
On line 25 it calls “if($fixslug == “”)” which I simply changed to “if($fixslug == ”)” as single quotes and double quotes can make a difference in php. If this doesn’t do the trick then you can just paste your old code into this file again to restore it. I’m going on a hunch here. When you have saved it just refresh and test. Let me know how the test goes?
-
This reply was modified 4 years, 10 months ago by
Carlo Merrick.
Altho the code is pretty messy, and the issue that @godseseun444 , there is an issue with the for-rent type being assigned.
This property is tagged as Commercial, however you do not include Commercial in your menu which is why is only displays under For Rent –> All :
https://casafinders.es/property/hairdressing-salon-leasehold-puerto-del-carmen-volc196852/See here – when using commercial as the type :
https://casafinders.es/forrent/?type=commercial&sortby=for-rentIs this intentional ? Or do you not want this property displaying under For Rent –> All ? Is the To Rent link supposed to only be limited to houses?
You don’t need custom anything really for this – so I think between the native wordpress functions, and the custom code, you are getting wonky behaviour in your results.
Hi @corrinarusso ,
Thanks again for all the advice. Originally on the site there wasn’t any pages set up for “For Sale” or “For Rent” but when the “For Sale” tab was pressed it would go to casafinders.es/forsale and all the properties for sale would be listed on a different page template that didn’t have a widget area.
I was trying to figure out a workaround so today I created 2 pages “For Sale” & “For Rent” and just changed the links on the menu bar urls for example:
before the url was : casafinders.es/forsale/apartment
and I replaced it with: casafinders.es/forsale/?type=apartment&sortby=for-saleBut before there was no properties showing at all and just a message “No Page Found”
I’m going to change the code that @godseseun444 edited and hopefully it will work for the time being. I think I’m going look for another theme that might suit better.
Thank you so much again for all your help !
I’m going to edit the code now and I’ll let you know how it goes.
Thank you so much again for all your help and advice!
This doesn’t make a lot of sense to me.
Do you have the original download of the theme files ?
https://themeforest.net/item/real-expert-responsive-real-estate-and-property-listing-wp-theme/6131977I would remove the custom code, and your existing theme – then just start again with this theme reloaded.
Yes I have the original download, I’ll try that first and see how I get on.
Thanks again
It is a pleasure @pauldeasy. If the code doesn’t correct it then I agree with @corrinarusso to simply load the theme with it’s defaults. Easiest way to have it run without any issues.
-
This reply was modified 4 years, 10 months ago by
- The topic ‘Problem with Page not found error’ is closed to new replies.