• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Exclude after header hook on certain pages

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Exclude after header hook on certain pages

This topic is: resolved

Tagged: After Header Hook, parallax-pro

  • This topic has 3 replies, 3 voices, and was last updated 6 years, 6 months ago by ltucker7.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • September 7, 2016 at 10:51 am #192757
    ltucker7
    Participant

    I'm looking for some help with some code for this. Here is what I've tried so far, but it's not working. It excludes the after header hook on the pages specified, but doesn't run the content in the hook itself.

    Specifically, I'm trying to exclude this on the home page and all landing pages, if that helps.

    Any help would be appreciated.

    function call_to_action() {
        $pages_to_exclude = array('2786', '3497');
        if (is_page($pages_to_exclude)) {
            return;
        } else {
           add_action( 'genesis_after_header', 'mailing_list_post_widget' );
    	function mailing_list_post_widget() {
    		genesis_widget_area( 'mailing-list', array(
    			'before' => '<div class="mailing-list widget-area"><div class="wrap">',
    			'after' => '</div></div>',
    	) );
    }
        }
    }
    https://lauratucker.com/7strategies/
    September 7, 2016 at 11:01 am #192758
    Victor Font
    Moderator

    I would rewrite this, this way:

    add_action( 'genesis_after_header', 'mailing_list_post_widget' );
    function mailing_list_post_widget() {
        $pages_to_exclude = array('2786', '3497');
        if ( is_page($pages_to_exclude) ) {
            return;
        } else {
    	    genesis_widget_area( 'mailing-list', array(
    		    'before' => '<div class="mailing-list widget-area"><div class="wrap">',
                'after' => '</div></div>',
            ));
        }
    }

    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    September 7, 2016 at 11:38 am #192764
    Scott G.
    Member

    I'm not sure how you have it set up, so this may or may not help.

    If you can put your hook into a widget, then you can completely control where that widget appears (page, post, etc.) with the right plugin. I use a plugin called Widget Logic (free plugin). It works great, but can be a bit cumbersome to use. I am a new user with Genesis, so I have NOT tried Widget Logic yet on Genesis themes.

    If this does work for you, you can put your hook and content in two separate widgets, so you can independently control where they appear.

    September 7, 2016 at 1:01 pm #192771
    ltucker7
    Participant

    Thank you so much Victor! It's perfect!

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble