[Resolved] Conditional for GP Hooks

Home Forums Support [Resolved] Conditional for GP Hooks

Home Forums Support Conditional for GP Hooks

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #327119
    Jam

    Hi

    I have a few hooks that I only want in certain pages.

    For a hook that’s excluded on the homepage, I use this:

    <?php if ( ! is_front_page() ) : ?>
         content
    <?php endif; ?> 

    My questions are:

    1) how should the conditional be if I want this same hook to be excluded in
    – homepage
    – categories
    – pages
    – archives

    that is, I only want it on individual posts

    2) And what’s the code if I only want it on individual pages and posts?

    Thanks a lot

    #327186
    Leo
    Staff
    Customer Support

    Hi there,

    1)

    <?php if ( is_single() ) : ?>
         content
    <?php endif; ?> 

    2)

    <?php if ( is_single() || is_page() ) : ?>
         content
    <?php endif; ?> 

    More info here: https://codex.wordpress.org/Conditional_Tags

    #328080
    Jam

    Great! Thanks for the quick reply, Leo!

    #328102
    Leo
    Staff
    Customer Support

    Glad I could help 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.