Agentpress is a popular Genesis Child theme for Real Estate sites. The theme uses a free plugin “Agentpress Listings” to list the properties and comes with 2 widgets. By default “Agentpress – Featured Listings” widget shows the price, custom text, address, city, state and zip code. Adding the following snippet to the theme’s functions.php allows the addition of an extra feature without modifying the plugin itself thus allowing the plugin to be updated. In the following example I have added the number of “bedrooms”.
Here is the snippet:
add_filter('agentpress_featured_listings_widget_loop', 'gd_add_feat_bedroom', 10, 1);
function gd_add_feat_bedroom( $loop ){
$br = '';
$bedrooms = get_post_meta( get_the_ID(), '_listing_bedrooms', true);
$sing_pul = ( (int) $bedrooms > 1 ) ? 'bedrooms' : 'bedroom';
if( $bedrooms ):
$br = sprintf( '%s %s', $bedrooms, $sing_pul );
$needle = "";
//find length of the needle
$needle_len = strlen($needle);
//find postion
$position_num = strpos($loop,$needle) + $needle_len;
//cut the string
$loop = substr($loop,0,$position_num) . $br . substr($loop,$position_num);
endif;
return $loop;
}
Note: Add the code in your functions.php file.