Site logo

Archived topic

GP Hooks - Before Content

5 replies · Started by Matt on February 15, 2018

Viewing posts 1–6 of 6

I'm currently using a hook for a category (18) for job posts.. that adds "Position Available" above the content...

<?php if ( is_category( '18' ))
{
echo 'Position Available';
}
?>

it works fine on the category feed.. but "Position Available" doesn't show up when posts are also displayed on the home page feed.. only in the category feed. Is there a way to have it displayed on both feeds.. but ONLY those category posts.. and not the other posts that appear on the home page feed?

thx
Matt

Hi there,

Can you try:

<?php if ( is_category( '18' ) || is_front_page() && is_home() && in_category( '18' ) ) {
    echo 'Position Available';
}
?>

thanks for the quick reply!
unfortunately.. that didn't work.

I wonder if has_category() would work better?

if ( has_category( '18' ) ) {

}

that did it.. thanks so much!

it also displays on the actual post as well now.. whereas before it only displayed in the category feed (summary). it now displays everywhere for posts from that category.

thanks for taking the time.. you guys are awesome!

Matt

Glad I could help! :)

This archived topic is closed to new replies.