Skip to content

Instantly share code, notes, and snippets.

@propertyhive
propertyhive / php
Last active March 23, 2016 13:26
Add location field to PropertyHive search form
add_filter( 'propertyhive_search_form_fields_default', 'update_ph_search_form_fields', 10, 1 );
function update_ph_search_form_fields($fields)
{
$department_field = $fields['department'];
unset( $fields['department'] );
$fields = array_reverse($fields, true);
$fields['address_keyword'] = array(
'type' => 'text',
@propertyhive
propertyhive / gist:e437dd2465430c7cfce014f610f2f2bc
Last active June 15, 2016 14:23
Display map on Property Hive full details page
<div id="map_canvas" style="height:300px"></div>
<script src="http://maps.google.com/maps/api/js"></script>
<script>
var map; // Global declaration of the map
function initialize_map() {
@propertyhive
propertyhive / gist:6e2025af2687060553792661d0c0b2a5
Created July 1, 2016 09:49
Lobster Web Design Property Hive Search Form
add_filter( 'propertyhive_search_form_fields_shortcode', 'edit_property_search_form_shortcode_fields', 1, 1 );
function edit_property_search_form_shortcode_fields($form_fields)
{
// Change the labels from 'Sales' and 'Lettings' to 'Buy' and 'Rent'
$form_fields['department']['options']['residential-sales'] = 'Buy';
$form_fields['department']['options']['residential-lettings'] = 'Rent';
$form_fields['address_keyword'] = array(
'type' => 'text',
'show_label' => false,
<?php
/**
* Single Property Images
*
* @author PropertyHive
* @package PropertyHive/Templates
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php
/**
* Loop Summary
*
* @author PropertyHive
* @package PropertyHive/Templates
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php
/**
* Make enquiry action, plus lightbox form
*
* @author PropertyHive
* @package PropertyHive/Templates
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
add_action( 'propertyhive_property_query', 'custom_field_property_filter' );
function custom_field_property_filter( $q ){
global $post;
if (is_post_type_archive( 'property' ))
{
if ( isset($_GET['my_field']) && $_GET['my_field'] != '' ) // YOUR CRITERIA HERE
{
$meta_query = $q->get( 'meta_query' );
@propertyhive
propertyhive / gist:5d017385cc7dbd844616818889258e1b
Created July 25, 2016 14:41
Russell Map View Followed by List
add_action( 'init', 'show_map_by_default', 1 );
function show_map_by_default()
{
$_GET['view'] = 'map';
}
add_action( 'init', 'maintain_property_list', 1 );
function maintain_property_list()
{
add_filter( 'propertyhive_show_results', create_function( '', 'return true;' ), 10 );
add_action( 'propertyhive_after_search_results_loop_item_title', 'jons_propertyhive_search_address', 7 );
add_action( 'propertyhive_after_search_results_loop_item_title', 'jons_propertyhive_search_bedrooms', 8 );
function jons_propertyhive_search_address() {
?>
<div class="address">
<?php echo $property->get_formatted_full_address(); ?>
</div>
<?php
}
<?php
/**
* Loop Price
*
* @author PropertyHive
* @package PropertyHive/Templates
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly