• 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

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 › Hooks

This topic is: not resolved

Tagged: conditional tags, exclude pages

  • This topic has 6 replies, 2 voices, and was last updated 9 years, 10 months ago by Brad Dalton.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • December 21, 2016 at 8:45 pm #197974
    hillyut
    Member

    Hi, I am trying to suppress a simple hook on a few of my lesson pages, like this one:
    http://www.pullingcurls.com/course/online-prenatal-class-couples (they use LIfterLMS)
    I don't like having my header "ads" up there as they are paid classes.
    I did get rid of the header and sidebar with this code:
    .single-course .site-container .nav-primary,
    .single-course .site-container .nav-secondary,
    .single-course .site-container .site-header,
    .single-lesson .site-container .nav-primary,
    .single-lesson .site-container .nav-secondary,
    .single-lesson .site-container .site-header {
    display: none;
    }

    On the hook I was trying to use this (using the conditional tags that Lifter gave me):

    <?php
    if (!is_lesson() ) || !is_course() || !is_archive() )
    { ?>

    //insert code for ad here
    <?php }
    ?>

    But when I execute php on that simple hook it throws and error and the rest of my site won't load.
    My host said that something is wrong with that coding.

    Is there ANY way to do it? Is there a way to add one of the hooks to that top code that says display none?

    Thanks!
    Hilary

    http://www.pullingcurls.com/course/online-prenatal-class-couples
    December 21, 2016 at 9:04 pm #197975
    Brad Dalton
    Participant

    I suggest you use PHP code in your functions file to load the advert and include conditional tags with the NOT operator to exclude pages.

    add_action('genesis_before_loop', 'your_function');
    function your_function() {
    if ( !is_lesson() ) || !is_course() || !is_archive() ) {
    echo '<div class="advert"> Add Your Text or HTML Here</div>';
        }
    }
    

    You can swap out genesis_before_loop with any hook


    Tutorials for StudioPress Themes.

    December 24, 2016 at 7:18 am #198071
    hillyut
    Member

    Brad, thank you so much! I'm going to try this right after work!

    December 26, 2016 at 7:54 am #198214
    hillyut
    Member

    Ok, I tried it -- but it throws this error: [26-Dec-2016 13:49:09 UTC] PHP Parse error: syntax error, unexpected '||' (T_BOOLEAN_OR) in /home/nginx/domains/pullingcurls.com/public/wp-content/themes/lifestyle-pro/functions.php on line 124

    Any chance I'm putting it in the wrong spot? I'm always nervous in the functions file....

    December 26, 2016 at 8:09 am #198216
    Brad Dalton
    Participant

    Try this:

    add_action('genesis_before_loop', 'your_function');
    function your_function() {
    if ( ! is_lesson() || ! is_course() || ! is_archive() ) {
    echo '<div class="advert">Add Your Text or HTML Here</div>';
        }
    }
    

    Tutorials for StudioPress Themes.

    December 29, 2016 at 8:17 am #198412
    hillyut
    Member

    Ok, that didn't throw an error. BUT, it also didn't work.
    Is there a way to add it to the css file like above?

    .single-course .site-container .nav-primary,
    .single-course .site-container .nav-secondary,
    .single-course .site-container .site-header,
    .single-lesson .site-container .nav-primary,
    .single-lesson .site-container .nav-secondary,
    .single-lesson .site-container .site-header {
    display: none;
    }

    December 29, 2016 at 8:34 am #198414
    Brad Dalton
    Participant

    The code works however it uses the conditionals you supplied ( which come from Lifter ) so you will need to check them. Its example code you can modify.

    Here's the WordPress conditionals you can swap out in the code.

    Or

    You can use CSS to hide the ads using the body classes which you can inspect in the HTML source code.


    Tutorials for StudioPress Themes.

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

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