- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I would like to show something only if on specific category or subcategory page.
Example, PGA is cat ID 2:
http://www.mysite.com/category/PGA/
http://www.mysite.com/category/PGA/swingers
These attempts don’t work…
<?php global $post;
if ($post->post_parent == 2) {
echo “test”;
} ?>
<?php if (in_category(‘CFB’)) : ?>
test
<?php endif; ?>
if ( get_query_var('CAT-SLUG') ) {
// do stuff here
}
Not working :(
<?php if ( get_query_var('pga') ) {
echo "test";
}
?>
Sorry was on my mobile when I replied to this last time. This is the correct code, if you’re on category.php
template.
$category = single_cat_title('', false);
if ( $category == 'test' ) {
echo 'on test category';
}
That works, but I would like the child category to apply as well.
Tried a number of things like this, doesn’t work…
<?php $category = single_cat_title('', false);
$parentcategory = get_category_parents('', false);
if ( $category == 'pga' || $parentcategory == 'pga') {
echo 'pga cat';
}
?>