WP Residence Help WP Residence Help

  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code Required, WpResidence 5.0 / Implementing Responsive Design for WPResidence Headers

Implementing Responsive Design for WPResidence Headers

170 views 0

Implementing Responsive Design for WPResidence Headers

Creating a responsive header is crucial for ensuring your real estate website looks great and functions well on all devices. WPResidence provides a solid foundation for responsive design, but you can further customize and enhance the responsiveness of your headers. This guide will walk you through the process of implementing a fully responsive header design in WPResidence.

Understanding WPResidence’s Built-in Responsiveness

WPResidence comes with a responsive framework out of the box. The theme uses media queries to adjust the layout and styling of elements, including headers, based on screen size. However, you may want to fine-tune this responsiveness to better suit your specific design needs.

Customizing Breakpoints

WPResidence uses standard breakpoints, but you can customize these in your child theme. Add the following to your child theme’s functions.php:


function custom_responsive_breakpoints($breakpoints) {
$breakpoints['phone'] = 480;
$breakpoints['tablet'] = 768;
$breakpoints['desktop'] = 1024;
return $breakpoints;
}
add_filter('wpresidence_responsive_breakpoints', 'custom_responsive_breakpoints');

Adjusting Header Layout for Mobile

To create a more compact header for mobile devices, add this to your child theme’s style.css:


@media only screen and (max-width: 768px) {
.header_wrapper {
padding: 10px 0;
}
.logo {
max-width: 150px;
}
.navbar-nav > li > a {
padding: 5px 10px;
}
}

Implementing a Mobile Menu

WPResidence includes a mobile menu by default, but you can customize its appearance and behavior. First, ensure the mobile menu is enabled in your theme options. Then, add this to your child theme’s style.css:


@media only screen and (max-width: 768px) {
.mobile_header {
display: block;
}
.navbar-toggle {
display: block;
}
.navbar-collapse.collapse {
display: none !important;
}
.navbar-collapse.collapse.in {
display: block !important;
}
}

Adjusting Font Sizes Responsively

Ensure your header text is readable on all devices by adjusting font sizes responsively:


@media only screen and (max-width: 768px) {
.navbar-nav > li > a {
font-size: 14px;
}
}
@media only screen and (max-width: 480px) {
.navbar-nav > li > a {
font-size: 12px;
}
}

Creating a Collapsible Search Bar

If your header includes a search bar, you might want to make it collapsible on smaller screens. Add this to your child theme’s functions.php:


function add_collapsible_search() {
if (wp_is_mobile()) {
echo '<div class="mobile-search-trigger"><i class="fas fa-search"></i></div>';
echo '<div class="mobile-search-wrapper">';
get_template_part('templates/advanced_search');
echo '</div>';
}
}
add_action('wpresidence_after_header', 'add_collapsible_search');

Then, style it in your child theme’s style.css:


@media only screen and (max-width: 768px) {
.mobile-search-wrapper {
display: none;
position: absolute;
top: 100%;
left: 0;
right: 0;
background: #fff;
padding: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.mobile-search-trigger {
display: block;
cursor: pointer;
}
}

Implementing Sticky Header for Desktop Only

You might want to use a sticky header on desktop but not on mobile. Add this to your child theme’s functions.php:


function sticky_header_script() {
if (!wp_is_mobile()) {
wp_enqueue_script('sticky-header', get_stylesheet_directory_uri() . '/js/sticky-header.js', array('jquery'), '1.0', true);
}
}
add_action('wp_enqueue_scripts', 'sticky_header_script');

Create a file named sticky-header.js in your child theme’s js folder:


jQuery(document).ready(function($) {
var header = $('.header_wrapper');
var headerOffset = header.offset().top;
$(window).scroll(function() {
if ($(window).scrollTop() > headerOffset) {
header.addClass('sticky');
} else {
header.removeClass('sticky');
}
});
});

Testing Responsiveness

After implementing these changes, thoroughly test your header on various devices and screen sizes. Use browser developer tools to simulate different screen sizes and check for any layout issues or functionality problems.

Using WordPress Customizer for Responsive Preview

Leverage the WordPress Customizer for live previews of your responsive design. Add this to your child theme’s functions.php to enable responsive previews in the Customizer:


function add_responsive_previews($wp_customize) {
$wp_customize->add_section('responsive_preview', array(
'title' => __('Responsive Preview', 'wpresidence-child'),
'priority' => 200,
));
$wp_customize->add_setting('responsive_preview_setting', array(
'default' => 'desktop',
'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control('responsive_preview_control', array(
'label' => __('Preview Size', 'wpresidence-child'),
'section' => 'responsive_preview',
'settings' => 'responsive_preview_setting',
'type' => 'radio',
'choices' => array(
'desktop' => __('Desktop', 'wpresidence-child'),
'tablet' => __('Tablet', 'wpresidence-child'),
'mobile' => __('Mobile', 'wpresidence-child'),
),
));
add_action('customize_register', 'add_responsive_previews');

By implementing these responsive design techniques, you can ensure that your WPResidence header looks great and functions well across all devices. Remember to always test thoroughly and make adjustments as needed to provide the best possible user experience for your real estate website visitors.

Technical how to | Custom Code RequiredWpResidence 5.0

Related Articles

  • Introduction to WPResidence Header Customization
  • Understanding WPResidence Header Types: An Overview
  • Customizing the WPResidence Logo Display
  • Configuring the Primary Navigation Menu in WPResidence

WP Residence Documentation

  • 1. General
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 2. Installation
  • 3. Installation FAQ
  • 4. Advanced Search
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 5. Agent, Agency & Developers
  • 6. Property Page
  • 7. Properties List
  • 8. Property Taxonomies
  • 9. Property Custom Template
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • Theme Options
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • Translation
  • FAQ
  • Pages
  • Header
  • Footer
  • Google or Open Street Maps
  • Payment Options
  • Plugins
    • Included Plugins
    • Third Party Plugins – IDX Compatibility
    • Third Party Plugins – Multi Languages
    • Third party Plugins – Other
  • Technical
    • Technical how to | Custom Code Required
    • Technical: Child Theme
  • Theme Updates

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API