1. Docs
  2. Developer Guide
  3. Handling Off Market Properties

Handling Off Market Properties

When a property comes off of the market we don’t remove it from WordPress. The reason being that you’d end up with a whole host of 404 errors which isn’t good for SEO. It’s also not a bad thing to keep old property data index-able as it means more content for your site.


Alerting Users To The Fact a Property Isn’t On The Market

When a property comes off the market, should a user stumble across the URL (maybe from an old match email, or Google) they will get shown a message alerting them to the fact that it’s no longer available. That is assuming you’re using the default templates. Should you wish to edit this message or it’s HTML and override the template, it can be found at the following location:

/wp-content/plugins/propertyhive/templates/single-property/not-on-market.php


Redirect Off-Market Property URLs

In the past we’ve had it requested that instead of showing the old off market property details, the user should be redirected to another page. That would indeed remove the issue of having a bunch of 404’s.

To achieve this you could add the following code to your theme’s functions.php file:

add_action( 'template_redirect', function (){
    if (is_singular('property')) {
        $on_market = get_post_meta(get_the_ID(), '_on_market', TRUE);
        if ('' == $on_market) {
            wp_redirect(get_post_type_archive_link('property'), 301);
            exit;
        }
    }
}, 5 );

The above would redirect the user to the search  results page should you visit the URL of an off-market property.


Clearing Down Media For Off Market Properties

Over time, as properties come on and off of the market, you’re going to end up with old media being stored belonging to these old properties.

If you’re using our Property Import add on to import properties there is a setting that allows you to choose what to do with old media when a property is removed.

Note that changing this setting will only effect imports and properties removed going forward.

If you’re not using our Property Import add on, at the moment it will be a case of manually going through and removing old properties and/or media.

Was this article helpful to you? Yes No