• 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

Two conditional tags in one hook

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 › Two conditional tags in one hook

This topic is: not resolved

Tagged: conditional tags, shortcodes, Simple Hooks

  • This topic has 4 replies, 2 voices, and was last updated 10 years, 6 months ago by Victor Font.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • August 13, 2015 at 1:29 pm #162281
    msongbird
    Participant

    I am using Genesis Simple hooks to add conditional tags.

    I want to use one hook to display a slider on the homepage only and in that same position (hence same hook) to display a table on category pages.
    After googling for hours and going way back into these forum archives. I came up with this code:

    <?php }
    if ( is_single() ) { ?>
    <div id="meteor-slideshow-wrap">
    [meteor_slideshow slideshow="homepage-slider"]
    </div>
    <?php }

    elseif ( is_category(6) ) { ?>
    [table id=1 /]
    <?php }

    But it doesn't work. I just can't seem to figure out how to add two conditional tags into the same hook area.

    Help appreciated.
    Marianne

    http://www.songbirdblog.com/decorating-gallery
    August 13, 2015 at 1:59 pm #162286
    Victor Font
    Moderator

    You're logic isn't correct. Is_single is true for any post regardless of category. In your logic, is_single executes first. Since it is true for every post, you will never get to test for the category. So the way your if statement reads logically is, "if this is a post, execute the home page slider and if it's not a post display the table if the category is 6." You're not testing for the home page and you're testing non-posts for a category. Neither condition will ever provide the result you want.

    What you want to do is this:

    <?php }
    if ( is_home () || is_front_page()  ) { ?>
    <div id=”meteor-slideshow-wrap”>
    [meteor_slideshow slideshow=”homepage-slider”]
    </div>
    <?php }
    elseif ( is_single() && is_category( '6' ) ) { ?>
    [table id=1 /]
    <?php }

    Regards,

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

    August 13, 2015 at 2:07 pm #162290
    Victor Font
    Moderator

    Actually, the code I gave you is wrong. In your OP, you said you want the table to display on category pages. If that's true, this is the correct code:

    <?php }
    if ( is_home () || is_front_page()  ) { ?>
    <div id=”meteor-slideshow-wrap”>
    [meteor_slideshow slideshow=”homepage-slider”]
    </div>
    <?php }
    elseif ( is_category( ) ) { ?>
    [table id=1 /]
    <?php }

    Regards,

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

    August 13, 2015 at 2:26 pm #162296
    msongbird
    Participant

    Hi Victor,
    Thanks for wanting to help.
    The single conditional tag was actually a typo, and should indeed have been is_home.

    Alas your code does not work. In fact it doesn't even render the slideshow on the homepage.

    I have gotten so far as rendering the slideshow on the homepage as wanted.
    When adding my second conditional tag in that hook I have been able to render the table BUT alas it showed up in the same div as the slideshow on the home page.

    Apart from not knowing how to combine the codes it seems as if a more pressing problem is that my shortcode won't work on category pages at all.
    I have tried replicating the exact code I successfully use in that hook for the homepage and just change the conditional tag to the category page, with no results

    Seems as if even used in the hooks section with "execute short code on this hook" I can't make a shortcode render on a category page.

    August 13, 2015 at 5:31 pm #162322
    Victor Font
    Moderator

    When I have to do things like this, I use the Genesis simple hooks plugin. It makes the work and code execution much easier.


    Regards,

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

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