• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

nSiteful Web Builders

Building a Better Web - One Site at a Time.

  • Home
  • About
    • Testimonials
    • Resources
    • Partner With Me
    • Frequently Asked Questions
  • Web Sites
  • Online Marketing
  • WordPress Support
    • Customized WordPress Training
    • 60-for-60 Sessions
  • Web Applications
  • Blog
    • At-A-Glance
    • Blog Articles Grouped by Category
    • Case Studies
    • General
    • Portfolio
    • Reviews
    • Snippets
    • Techniques
    • Projects
  • Contact
    • Purchase Retainer Consulting Hours
    • About Retainer Consulting Hours
    • Book a Meeting with Jeff
    • Tell Me About Your Web Project
    • nSiteful Newsletter Archives
    • nSiteful Rewards
Mai Lifestyle Pro Banner

By Jeff - 6/15/2020
Cats: Snippets · Tags: Genesis, Mai Lifestyle Pro, WordPress

snippets

Genesis: How to Hide the Mai Lifestyle Pro Banner Area With Code

Last updated May 9th, 2024 at 02:57 pm

Mai Lifestyle Pro, a popular Genesis child theme, supports banner areas after the header. (Check out the live demo here.) Banner areas with banner images — not unlike featured images — can add interest to a post and provide subliminal context.

Here’s an example from the Mai Lifestyle Pro demo. The area bounded by the red rectangle is the banner area.

Mai Lifestyle Pro Banner
Click to enlarge

However, the defaults for the banner area might not always give you the results you want.

The Problem: Mai Lifestyle Pro Defaults

I have a site on which I want banner images to display in the banner areas of only a very few posts. For all other posts, I want the banner area to be hidden. For the sake of discussion, I’ll focus on “pages”, and let’s suppose the site has 100 pages, only 3 of which I want to display banner images.

The way the customization options for the Mai Banner Area work, you must globally enable the Banner Area for a post type if you want it to show up on ANY post. The problem is that every page will, by default, display the Banner Area. Here’s what you get for posts that don’t have a banner image assigned:

Mai Lifestyle Pro Default Banner
Click to enlarge

I don’t want that. I don’t want the post title taking up so much real estate. And I certainly don’t want to have to manually hide the banner area for each of 97 pages by checking the Hide banner area checkbox in the Visibility Settings box of each page.

At first, I thought I could accomplish my goal by globally DISabling the Banner Area and then selectively unchecking the Hide banner area checkbox option for the 3 pages on which I want the banner area to appear. But this doesn’t work because when the Mai Banner Area is globally disabled, the Hide banner area option in the Visibility Settings box is not available.

The Solution in English: Hiding the Mai Lifestyle Pro Banner Area

I wrote a function that will display the Mai Banner Area for a page only if:

  1. a banner image is attached to the page
    AND
  2. the Hide banner area option is unchecked

(You might think I’d need just the first condition, but that’s not always going to work. Sometimes a banner image will be assigned and minds will change about displaying the banner area. Since minds that change can change again, it’s safest to simply check the Hide banner area option and not delete the banner image).

Stated in the reverse (which is actually the way the function is coded), the Mai Banner Area will be removed for any page if:

  1. NO banner image is attached
    OR
  2. the Hide banner area option is checked

The Solution In Code: Hiding the Mai Lifestyle Pro Banner Area

function nwb_mai_banner_display() {
	global $post;
	$is_banner_attached = metadata_exists('post', $post->ID, 'banner' );
	$is_banner_hidden = 
		( metadata_exists('post', $post->ID, 'hide_banner' ) 
		&& '1' === get_post_meta($post->ID, 'hide_banner', true) );
	
	/** 
	 * Remove the banner area if either:
	 * a) no banner image is attached or 
	 * b) a banner image IS attached BUT 'Hide Banner Area' is checked
	 */
	if ( ! $is_banner_attached  
		|| ( $is_banner_attached && $is_banner_hidden ) ) {
		remove_action( 'genesis_after_header', 'mai_do_banner_area', 20 );
	}
}
add_action( 'genesis_before', 'nwb_mai_banner_display' );

Place this code in the child theme’s functions.php file.

Explanation:

  • Line 3: I like to keep things readable, so I’m defining this variable so it can be used further on in the function. Let’s just see if there’s a banner image attached, shall we? When a banner image is attached to a post, WordPress adds a row to the post_meta table with the post ID of the post, a key of ‘banner’, and the URL of the banner image as the value. If no banner image is attached, this condition will evaluate to false. The metadata_exists() function does pretty much what it sounds like.
  • Line 4: Again, I’m defining a variable for use further down, for readability. Let’s find out if the Hide banner area option is checked for the current post.
  • Line 5: I’m not 100% sure of this, but I believe a record with the ‘hide_banner’ meta key is entered into (or modified in) the post_meta table only if you change the status of the Hide banner area option from its default at least one time. So if you never did that, there would be no such metadata, and the script would choke here. Thus the use of metadata_exists in conjunction with the get_post_meta() call on the next line.
  • Line 6: Get the value of the hide_banner meta_key for the current post. The possible values are ‘0’ (false, not hidden) and ‘1’ (true, hidden’). I’m using the three equal signs for exact match.
  • Lines 13 -14: Here’s the condition, using the variables defined at the top. If there is no banner image attaced, or even if there is but the Hide banner area option is checked, then remove the banner area.
  • Line 15: Using the remove_action function with gnesis_after_header as the hook. The function we’re removing is mai_do_banner_area: the function that, well, “does the banner area”.
  • Line 18: Finally, we need to invoke this custom function, using the genesis_before hook.

If you found this article helpful, please consider sharing. Your feedback is welcome. Either fill out the short survey below and/or comment below.

And if you’d like to receive notifications of new article in your inbox, subscribe to my newsletter.

Like what you see? Share with others and join my mailing list. No long-term commitment, unsubscribe any time.

Related Posts

  1. Dive Into WordPress Custom Post Types – Part 3
  2. Unfollow-A-Huckster Wednesday
  3. Offer Live Chat for Enhanced Customer Engagement and Sales
  4. WordPress Manual Excerpts: Why, When, & How to Use Them
  5. Sharing Blog Posts on Social Networks: Why & How

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

mailchimp signup

Subscribe to get notified when new articles are published. Unsubscribe any time. No spam. I promise. Check out my newsletter archives.

social

Twitter Facebook LinkedIn

Recent Articles

  • Post-Specific CSS for WordPress October 5, 2026
  • You built an online course, but they haven’t come. September 16, 2026
  • Custom MemberPress Pricing Pages December 19, 2025
  • CSS Data Attribute Override December 11, 2025
  • MemberPress Rules Using Custom Taxonomies and Custom Roles December 10, 2025

Filter By Category/Tag

Categories

  • Case Studies (8)
  • For Staff (1)
  • General (73)
  • Portfolio (7)
  • Reviews (14)
  • Snippets (24)
  • Techniques (52)

Popular Tags

Advanced Custom Fields Blogging Child Themes Content Marketing CSS Customer Service Custom Fields Custom Post Types Diagnostics Domain Names Facebook FooGallery Genesis Hosting HTML Images iPhone Libra Live Chat Marketing Media MemberPress MemberPress Courses Membership Sites Mobile-Friendly MySQL Photo Gallery php Pinterest Plugins Post Formats Pricing Project Management SEBA SEO Seth Godin Shortcodes Social Networking Surveys Taxonomies Twitter Video Web design Web forms WordPress

Footer

Background

Web Sites | WordPress Support | Web Applications.

Formally trained in liberal arts and education (I have a B.A. in Government from Harvard and studied Secondary Education at Rutgers Graduate School), I have honed my skills in the communication arts and sciences as a teacher, trainer, instructional designer, writer, photographer, calligrapher, helpdesk manager, database programmer, and multimedia developer.

(I've also been a group counselor, waiter, bartender, bicycle messenger boy, computer salesman, carpenter's helper, financial analyst, and school board president.)

Tech

Systems since 1983.
Web sites since 1994.
PHP since 2001.
WordPress since 2007.

Contact

Book Meeting
770-772-5134
Email Jeff
Send Money
All Ways

Copyright 2026, nSiteful Web Builders, Inc.

Cookies Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}
https://iframe.mediadelivery.net/embed/392008/42d18bc1-2adc-4741-b733-053d08d09c32
https://vz-000c5976-3ab.b-cdn.net/42d18bc1-2adc-4741-b733-053d08d09c32/play_720p.mp4

Receive occasional emails from Jeff