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 / Adding Custom CSS Classes to WPResidence Headers

Adding Custom CSS Classes to WPResidence Headers

286 views 0

Customizing your WPResidence theme’s header with custom CSS classes allows for granular control over its appearance and functionality. This guide will walk you through the process of adding and utilizing custom CSS classes for your WPResidence headers.

Understanding WPResidence Header Structure

Before we dive into adding custom classes, it’s important to understand the basic structure of WPResidence headers. The main header wrapper typically has a class structure like this:


<div class="header_wrapper header_type1 header_align_left header_wide_no">
<!-- Header content -->
</div>

Adding Custom Classes via Theme Options

WPResidence provides options to add custom classes directly through the theme settings:

  1. Navigate to WPResidence Options in your WordPress dashboard
  2. Go to the ‘Header’ tab
  3. Look for the ‘Add custom class to header’ option
  4. Enter your custom class name(s)
  5. Save changes

This functionality is controlled by the following code in the theme options:


array(
'id' => 'wp_estate_header_custom_class',
'type' => 'text',
'title' => __('Add custom class to header', 'wpresidence-core'),
'subtitle' => __('Add custom class to header wrapper', 'wpresidence-core'),
),

Adding Custom Classes via Child Theme

For more advanced customization, you can add classes through your child theme’s functions.php file:


function add_custom_header_class($classes) {
$classes[] = 'my-custom-header-class';
return $classes;
}
add_filter('wpresidence_header_classes', 'add_custom_header_class');

Utilizing Custom Classes for Styling

Once you’ve added custom classes, you can use them to apply specific styles. Add these styles to your child theme’s style.css file:


.my-custom-header-class {
background-color: #f0f0f0;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.my-custom-header-class .navbar-nav > li > a {
font-weight: bold;
text-transform: uppercase;
}

Creating Conditional Custom Classes

You can also add classes conditionally based on various factors. Here’s an example that adds a class for logged-in users:


function add_conditional_header_class($classes) {
if (is_user_logged_in()) {
$classes[] = 'logged-in-header';
}
return $classes;
}
add_filter('wpresidence_header_classes', 'add_conditional_header_class');

Customizing Header Elements with Custom Classes

Custom classes can be used to target specific header elements. For example, to style the logo area:


.my-custom-header-class .logo {
padding: 10px 0;
}
.my-custom-header-class .logo img {
max-height: 50px;
transition: all 0.3s ease;
}

Responsive Adjustments with Custom Classes

Leverage your custom classes to make responsive adjustments:


@media only screen and (max-width: 768px) {
.my-custom-header-class {
padding: 5px 0;
}
}

Technical how to | Custom Code RequiredWpResidence 5.0

Related Articles

  • Technical – How to Change the Minimum Image Dimensions for Property Uploads in WPResidence
  • Introduction to WPResidence Header Customization
  • Understanding WPResidence Header Types: An Overview
  • Customizing the WPResidence Logo Display

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
  • WpResidence Elementor Studio
  • 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

Join Us On

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