WP Residence Help WP Residence Help

  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code Required, WPResidence 5.0 Documentation / Header Media Actions and Filters

Header Media Actions and Filters

609 views 0

Extending WPResidence Theme with Actions and Filters

1. Actions in header_media.php

1.1 wpestate_before_header_media

This action is executed before the header media section begins.

Usage in child theme’s functions.php:

function my_custom_before_header_media() {
echo '<div class="custom-header-top">Custom content before header media</div>';
}
add_action('wpestate_before_header_media', 'my_custom_before_header_media');

1.2 wpestate_before_advanced_search

This action is executed before the advanced search is displayed.

Usage example:

function my_custom_before_advanced_search() {
if (is_front_page()) {
echo '<div class="search-intro">Find your dream property</div>';
}
}
add_action('wpestate_before_advanced_search', 'my_custom_before_advanced_search');

1.3 wpestate_after_advanced_search

This action is executed after the advanced search is displayed.

Usage example:

function my_custom_after_advanced_search() {
echo '<div class="search-tips">Need help? Check our search tips</div>';
}
add_action('wpestate_after_advanced_search', 'my_custom_after_advanced_search');

2. Filters in header-media-functions.php

2.1 wpestate_header_type

This filter allows modification of the header type for any page.

Usage example to force a specific header type for a certain page:

function my_custom_header_type($header_type, $post_id) {
if ($post_id == 123) { // Replace with your specific page ID
return 2; // Force image header type
}
return $header_type;
}
add_filter('wpestate_header_type', 'my_custom_header_type', 10, 2);

2.2 wpestate_global_header_type

This filter allows customization of the global header type for non-archive pages.

Usage example to change the global header type:

function my_custom_global_header_type($global_header_type) {
if (is_front_page()) {
return 3; // Use Revolution Slider for front page
}
return $global_header_type;
}
add_filter('wpestate_global_header_type', 'my_custom_global_header_type');

2.3 wpestate_header_media_class

This filter allows modification of the header media CSS class.

Usage example to add a custom class:

function my_custom_header_media_class($class) {
return $class . ' my-custom-header-class';
}
add_filter('wpestate_header_media_class', 'my_custom_header_media_class');

3. Extending Theme Slider Functionality

3.1 wpestate_theme_slider_contact

While not a direct action or filter, this function can be overridden in a child theme to customize the contact section in the theme slider.

Example of overriding in child theme’s functions.php:

function wpestate_theme_slider_contact($propid) {
// Custom implementation
$output = '<div class="custom-slider-contact">';
$output .= '<h3>Contact Agent</h3>';
$output .= '<a href="' . get_permalink($propid) . '#contact">Inquire Now</a>';
$output .= '</div>';
return $output;
}

4. Customizing Header Image Display

4.1 Overriding wpestate_header_image function

While not a direct filter, you can completely override the header image display by redefining the function in your child theme.

Example in child theme’s functions.php:

function wpestate_header_image($image) {
global $post;
if (is_single() && get_post_type() == 'estate_property') {
// Custom header for single property pages
$property_id = get_the_ID();
$header_image = get_post_meta($property_id, 'property_custom_header', true);
if (!empty($header_image)) {
echo '<div class="property-custom-header" style="background-image:url(' . esc_url($header_image) . ')"></div>';
return;
}
}
// Fall back to parent theme's implementation for other cases
include_once(get_template_directory() . '/header-media-functions.php');
wpestate_header_image($image);
}

5. Customizing Theme Slider

5.1 wpestate_theme_slider_height

This filter allows customization of the theme slider height.

Usage example:

function my_custom_slider_height($height) {
return 600; // Set slider height to 600px
}
add_filter('wpestate_theme_slider_height', 'my_custom_slider_height');

These examples demonstrate various ways to extend and customize the WPResidence theme using actions, filters, and function overrides in a child theme. By leveraging these hooks, you can significantly alter the theme’s functionality and appearance without modifying the parent theme files directly.

Technical how to | Custom Code RequiredWPResidence 5.0 Documentation

Related Articles

  • Webhook Integration for Contact Forms
  • Technical: Change the Schedule Tour Email Text and the Form Default Message
  • Property list filter customization
  • Technical – How to Change the Minimum Image Dimensions for Property Uploads in WPResidence

Help Categories

  • 19Agent, Agency & Developers
  • 7Blog Posts & Blog Lists
  • 38Elementor Shortcodes Built-In
  • 55FAQ
  • 15Footer
  • 5Getting Started
  • 37Header
  • 2IDX & MLSImport
  • 6Installation & Setup
  • 22Installation FAQ
  • 23Maps & Location Settings
  • 21Multi-Language Third Party Plugins
  • 6Other Third party Plugins
  • 19Pages
  • 4Payments & Monetization
  • 20Property Lists, Categories & Archive
  • 36Property Pages & Layouts
  • 31Search & Filtering
  • 163Technical how to | Custom Code Required
  • 8Technical: Actions and filters
  • 6Technical: Child Theme
  • 85Theme Options & Global Settings
  • 6Translations & Languages
  • 16WPBakery Shortcodes
  • 51WPResidence / WPEstate CRM
  • 50WPResidence 5.0 Documentation
  • 7WPResidence Elementor Studio
  • 50WPResidence Translate Plugin

Join Us On

Powered by WP Estate - All Rights Reserved
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API