Skip to content

Customizing property URLs

Jon Schroeder edited this page Oct 7, 2021 · 4 revisions

Here's our default filter that's automatically run against every property link before outputting that:

add_filter( 'rentfetch_filter_property_url', 'rentfetch_add_prefix_to_property_url', 10, 1 );
function rentfetch_add_prefix_to_property_url( $url ) {
    
    // force http:// to be added to the URL if it's missing
    if (strpos($url,'http') === false)
        $url = 'http://'.$url;
        
    return $url;
    
}

So, if we wanted to change that further, we could hook in again at a later priority (in a theme), like so:

add_filter( 'rentfetch_filter_property_url', 'fourstar_remove_incorrect_urls', 20, 1 );
function fourstar_remove_incorrect_urls( $url ) {

    if ( empty($url) )
        return null;
    
    // remove this if it's just the default
    if (strpos($url,'fourstarrealty.com') != false)
        $url = null;
        
    return $url;
    
}

Clone this wiki locally