WP Residence Help WP Residence Help

  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code / Header Media Actions and Filters – part 2

Header Media Actions and Filters – part 2

620 views 0

Extending WPResidence Theme with Actions and Filters – Part 2

1. Additional Actions in header_media.php

1.1 wpestate_before_header_media_content

This action is executed before the main header media content.

Usage in child theme’s functions.php:

function my_custom_before_header_media_content() {
echo '<div class="pre-header-content">Important announcement here</div>';
}
add_action('wpestate_before_header_media_content', 'my_custom_before_header_media_content');

1.2 wpestate_after_header_media_content

This action is executed after the main header media content.

Usage example:

function my_custom_after_header_media_content() {
echo '<div class="post-header-content">Check out our latest listings</div>';
}
add_action('wpestate_after_header_media_content', 'my_custom_after_header_media_content');

1.3 wpestate_before_mobile_search

This action is executed before displaying mobile search.

Usage example:

function my_custom_before_mobile_search() {
if (wp_is_mobile()) {
echo '<div class="mobile-search-tip">Tap to start your search</div>';
}
}
add_action('wpestate_before_mobile_search', 'my_custom_before_mobile_search');

1.4 wpestate_after_mobile_search

This action is executed after displaying mobile search.

Usage example:

function my_custom_after_mobile_search() {
if (wp_is_mobile()) {
echo '<div class="mobile-search-results">Your results will appear here</div>';
}
}
add_action('wpestate_after_mobile_search', 'my_custom_after_mobile_search');

2. Additional Filters in header-media-functions.php

2.1 wpestate_404_archive_header_type

This filter customizes header type for 404 and archive pages with Google Map taxonomy.

Usage example:

function my_custom_404_archive_header_type($header_type) {
if (is_404()) {
return 2; // Use image header for 404 pages
}
return $header_type;
}
add_filter('wpestate_404_archive_header_type', 'my_custom_404_archive_header_type');

2.2 wpestate_property_list_header_type

This filter customizes header type for property list pages.

Usage example:

function my_custom_property_list_header_type($header_type) {
if (is_post_type_archive('estate_property')) {
return 3; // Use theme slider for property archive
}
return $header_type;
}
add_filter('wpestate_property_list_header_type', 'my_custom_property_list_header_type');

3. Extending Theme Slider Functionality

3.1 wpestate_slider_cycle

This filter allows customization of the slider cycle time.

Usage example:

function my_custom_slider_cycle($cycle_time) {
return 7000; // Set slider cycle time to 7 seconds
}
add_filter('wpestate_slider_cycle', 'my_custom_slider_cycle');

3.2 wpestate_theme_slider_content

While not a direct filter, you can create this filter to modify the slider content.

First, in the theme slider function, add this filter:

$slider_content = apply_filters('wpestate_theme_slider_content', $default_content, $post_id);

Then in your child theme:

function my_custom_slider_content($content, $post_id) {
$custom_field = get_post_meta($post_id, 'custom_slider_text', true);
if (!empty($custom_field)) {
$content .= '<div class="custom-slider-text">' . esc_html($custom_field) . '</div>';
}
return $content;
}
add_filter('wpestate_theme_slider_content', 'my_custom_slider_content', 10, 2);

4. Customizing Header Image Display

4.1 wpestate_header_image_height

This filter allows customization of the header image height.

Usage example:

function my_custom_header_image_height($height) {
if (is_front_page()) {
return 800; // Set front page header height to 800px
}
return $height;
}
add_filter('wpestate_header_image_height', 'my_custom_header_image_height');

4.2 wpestate_header_overlay_opacity

This filter allows customization of the header overlay opacity.

Usage example:

function my_custom_header_overlay_opacity($opacity) {
if (is_single() && get_post_type() == 'estate_property') {
return 0.7; // Increase overlay opacity for single property pages
}
return $opacity;
}
add_filter('wpestate_header_overlay_opacity', 'my_custom_header_overlay_opacity');

These additional examples provide more ways to extend and customize the WPResidence theme using actions and filters in a child theme. By leveraging these hooks, you can further modify the theme’s functionality and appearance to meet specific requirements.

Technical how to | Custom Code

Related Articles

  • How to Add Custom Fields to the Login, Register and Forgot Password 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
MLSImportWordPress IDX Plugin for MLS ListingsImport MLS listings into your WordPress website, customize your property pages, and keep your inventory updated.Start free 30-day trial →

Help Categories

  • 111 Installation & Changelog
  • 19Agent, Agency & Developers
  • 5Blog Posts & Blog Lists
  • 14Footer
  • 38Header
  • 2IDX & MLSImport
  • 23Maps & Location Settings
  • 50Multilingual Websites – WPEstate Translate (Included)
  • 21Pages & Page Templates
  • 4Payments & Monetization
  • 20Property Lists, Categories & Archive
  • 38Property Single Page
  • 32Search & Filtering
  • 170Technical how to | Custom Code
  • 9Technical: Actions and filters
  • 6Technical: Child Theme
  • 86Theme Options & Global Settings
  • 6Theme Translation & Localization
  • 28Third Party Plugins Compatible
  • 16WPBakery Shortcodes
  • 51WPResidence / WPEstate CRM
  • 9WPResidence Elementor Studio
  • 39WPResidence Elementor Widgets
  • 79WPResidence FAQ

Join Us On

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