• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to user navigation

Designody

WordPress and Genesis Tutorials

  • Get Started
  • About
  • Archive
  • Services
  • Membership
  • My Account

Replace Header Right widget area conditionally in Genesis

Last Updated on September 14, 2018Leave a Comment Favorited: 1 times

You can replace the Header Right widget using this in functions.php

Make sure you have enabled header right widget area by default. Comment out the line to enable the header right widget area

//* Remove the header right widget area
    //unregister_sidebar( 'header-right' );

Now, use one of the following snippets.

Front page

//* Remove Header right Widget using conditional tag.
add_action( 'genesis_title', 'remove_header_right_widget', 9 ); // genesis_title, genesis_meta or wp_head
function remove_header_right_widget() {
    if ( ! is_front_page() ) {
        return;
    }
    //* Remove the header right widget area
    unregister_sidebar( 'header-right' );
}

Post Page i.e Blog

//* Remove Header right Widget using conditional tag.
add_action( 'genesis_title', 'remove_header_right_widget', 9 ); // genesis_title, genesis_meta or wp_head
function remove_header_right_widget() {
    if ( ! is_home() ) {
        return;
    }
    //* Remove the header right widget area
    unregister_sidebar( 'header-right' );
}

for Singular Posts

//* Remove Header right Widget using conditional tag.
add_action( 'genesis_title', 'remove_header_right_widget', 9 ); // genesis_title, genesis_meta or wp_head
function remove_header_right_widget() {
    if ( ! is_singular( 'post' ) ) {
        return;
    }
    //* Remove the header right widget area
    unregister_sidebar( 'header-right' );
}

There are various WordPress Conditional tags and you can use as per your post, page or category.
is_singular( ‘post’ )

You can also use an → array ( ‘post’,’book’ ) for multiple conditions and custom post types.

is_singular( array ( 'post','book' ) )

Important Reads:

  • WordPress Conditional Tags
  • Conditional Tags and Return Early in Genesis

Related Posts

  • Convert Search form into the widget area in Essence Pro theme
  • Slide in-out Menu in left, Title Area Logo in center and header widget in Right in Genesis Sample
  • Slide in-out Menu in left, Title Area Logo in center and header widget in Right forever in Genesis Sample
  • Primary menu in left, Logo in Center and Search widget in right in Genesis Sample
  • Add Header Left Widget In Genesis

Categories: Free Content, Genesis Tutorials, WordPress Tutorials Tags: header right

Reader Interactions

Leave a Reply Cancel reply

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

You should use these Shortcodes tag and attributes while sharing the code:
Example: [html]I <3 HTML[/html] → [html][css][php][js][java][json][raw]

Primary Sidebar

WPEngine WordPress Hosting, Perfected.

Hosting You are looking for?.
Perfect solution for small business to global enterprise.

Learn more

StudioPress Genesis Theme Framework

The No.1 Theme Provider.
Creative, SEO rich Theme for all niche projects.

Learn more

Categories

  • Free Content
  • Genesis Tutorials
  • Premium Content
  • Snippets
  • What's New?
  • WordPress Tutorials

Tag Cloud

Archive Background Section blog center logo columns conditional tags CSS CSS Grid custom Customizer custom post type Custom Post Types custom template Custom Widget effect Featured Image front-page Genesis Genesis Sample header right hero section Image Background js layout Logo menu navigation Navigation Menu Nav Menu newsletter post page related posts responsive menu search search widget Shrinking Logo site header slide in-out Split Navigation Stylesheet Template Utility Bar Video Background widgets WordPress

Built with Genesis Framework + WordPress

  • Contact
  • FAQ
  • Disclaimer
  • Privacy Policy
  • Copyright Policy
  • Terms of Service