Archived topic
After content
4 replies · Started by Cristina on March 2, 2017
Hi!
I have an image set after content in my posts, using <?php if ( is_single ( ) ) : ?> in the GP Hooks.
What I want to do now is to set a different image depending the post. I want the image that I already have in every post (just in posts, not in pages), except in the posts of a specific category, where I want to put another image.
Is it possible to do that?
Hi Christina,
Try something like this:
<?php if ( is_category( 'Category Name' ) ) : ?>
Let me know if this works.
To target a post inside a category, you would use the in_category() condition.
So you could do this:
<?php if ( in_category( 'Category Name' ) ) { ?>
Content for your "Category Name" category.
<?php } elseif ( in_category( 'Another Category' ) ) { ?>
Content for your "Another Category" category.
<?php } elseif ( is_single() ) { ?>
Content for all other single posts.
<?php } ?>
Thank you very much!! It worked! :)
You're welcome :)