Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Resolved] excluding category in gp hooks

Home Forums Support [Resolved] excluding category in gp hooks

Home Forums Support excluding category in gp hooks

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #467959
    Dale

    Hi there

    I have separate PHP hooks I use in the After Header hook area, one for the category for-readers and one for the category for-writers. Occasionally, a post falls into both categories and the content for both hooks shows up, which i don’t want (see linked page).

    I am using

    <?php
    if ( in_category( 'for-writers' ))
    { ?> ...

    and

    <?php
    if ( in_category( 'for-readers' ))
    { ?> ...

    followed by code for a mailing list sign up for the two separate groups.

    If a page falls into both categories, instead of both forms appearing, I’d rather have only the form for readers appear. How to I write the “for-writers” hook so it doesn’t appear on pages that are also in the category “for-readers”?

    #468075
    Leo
    Staff
    Customer Support

    Hi there,

    Try:
    if ( in_category( 'for-writers' ) && ! in_category( 'for-readers' ) )

    #469393
    Dale

    Thanks!

    #469512
    Leo
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.