• 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

Help with conditionals for action hooks

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 › Help with conditionals for action hooks

This topic is: not resolved
  • This topic has 9 replies, 3 voices, and was last updated 10 years, 3 months ago by sethbahookey.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • March 8, 2015 at 3:04 pm #143697
    sethbahookey
    Member

    Hello! I am trying to add a snippet of code to the bottom of my pages in my website. However, I only want it to show up on some pages and not on others. I'm trying to wrap a conditional around an action hook to let it know whether it needs to display or not. For some reason it is working backwards... See below.

    if( is_page() ) {
    add_action('genesis_entry_footer', 'hello_world');
    function hello_world() {
    echo "hello world";
    }
    }

    This should display a small hello world at the bottom of the entry section of this page, but it shows nothing!

    if( !is_page() ) {
    add_action('genesis_entry_footer', 'hello_world');
    function hello_world() {
    echo "hello world";
    }
    }

    When I turn it to "is not page" as the conditional then it pops up. So what the heck is going on here? My page is really a post? when I try is_single() that doesn't work either. Please help!

    thecompressioncloset.com

    http://thecompressioncloset.com
    March 8, 2015 at 4:03 pm #143705
    Brad Dalton
    Participant

    Add the conditional after the function


    Tutorials for StudioPress Themes.

    March 8, 2015 at 4:10 pm #143706
    sethbahookey
    Member

    Thanks for the response! Could you provide an example please? This is how I am understanding you...

    add_action(‘genesis_entry_footer’, ‘hello_world’);
    function hello_world() {
               if( is_page() ) {
                        echo “hello world”;
               }
    }

    The thing is I want to either add or remove an action hook based on whether I'm on a certain section of my site.

    So something like:

    if( !is_page('contact-us') || !is_page('about-us') ) {
    	add_action('genesis_entry_footer', 'wpmem_inc_sidebar');
    }

    wpmem_inc_sidebar is what I'm actually trying to insert into the site. The challenge is that it is not recognizing those conditionals :/

    March 8, 2015 at 4:16 pm #143710
    sethbahookey
    Member

    P.S. - I just put this in the site so you can see what I mean about it being on every page...

    thecompressioncloset.com

    if( !is_page('contact-us') || !is_page('about-us') ) {
    	add_action('genesis_entry_footer', 'wpmem_inc_sidebar');
    }
    March 8, 2015 at 4:17 pm #143712
    Brad Dalton
    Participant

    Your first snippet looks o.k

    As far as support for adding a plugins functionality, the best people to ask are the plugin Developers.

    Hard to provide support for 35,000+ plugins.


    Tutorials for StudioPress Themes.

    March 8, 2015 at 4:58 pm #143720
    sethbahookey
    Member

    Ok, either way, the conditionals aren't working regardless of plugin. So I'm wondering what went wrong there.

    March 8, 2015 at 11:10 pm #143746
    coralseait
    Member

    Do you already have an add_action for genesis_entry_footer somewhere in the code base?


    Coral Sea IT

    March 8, 2015 at 11:23 pm #143747
    Brad Dalton
    Participant

    Your first snippet looks fine to me. Where did you put the code because it should be in functions.php


    Tutorials for StudioPress Themes.

    March 10, 2015 at 5:25 am #143894
    sethbahookey
    Member

    Well I did a search through the whole WP folder and it looks like that 'genesis_entry footer is sprinkled throughout the post.php page.

    March 10, 2015 at 5:26 am #143895
    sethbahookey
    Member

    Yes I did place it within functions.php at the bottom of that page. Is there a way to do a check on the page itself to determine what it's page id is? I mean I've switched the permalinks back to default to get the page id that way, but still nothing!

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 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

© 2025 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