Site logo

Archived topic

excluding category in gp hooks

3 replies · Started by dale on January 10, 2018

Viewing posts 1–4 of 4

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"?

Hi there,

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

Thanks!

No problem :)

This archived topic is closed to new replies.