If / else statement to find if a post is featured or not?
-
Hi guys.
Is there a way I can add an if/else statement inside a page template to only display code if the post has been highlighted as a ‘featured post’?
I’ve found the code below as an example:
<?php if ( get_post_meta( get_the_ID(), 'featured', true ) ) : ?> <h3>SHOW IF FEATURED</h3> <?php else : ?> <h3>SHOW IF NOT FEATURED</h3> <?php endif;?>
… but it doesn’t work when I use it inside a particular post type.
Has anyone else managed to get WordPress to offer this functionality (the reason for the request is the website is a directory and my client wants to be able to show certain fields if a post is featured but hide them on other posts)
Or, if the code is correct, is there a way to get it to work on particular post types?
Thanks so much for your help ??
Phil
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘If / else statement to find if a post is featured or not?’ is closed to new replies.