I’m currently developing a wordpress blog site but I think this question maybe a bit of JS magic at the same time so put it here rather than WordPress Development.
I’m looking to create a post and have a certain div display on the post when a tag criteria is met e.g. if I tag a post with ‘crazy css trick’ I’m looking to display a badge on the post with ‘Crazy CSS tricks’ written on it. But also still allowing me to tag the post with multiple tags not just 1.
(This is similar to a ‘featured’ post and displaying a ‘Featured’ badge on the post)
This is WordPress
Would love to have this in the main loop.
Allowing Multiple Tags
Displaying a certain tag on the post in the form of a badge
Needs to be in main loop.
A site which does similar to this is VEVO which you can see here http://www.vevo.com/ on their slideshow they have ‘Exclusive’ ‘Original Show’ Etc.
Any help would be great, tried a few ways but they seem to either do ‘if’ statements for every post and not exactly great performance wise.
You could use a simple conditional and check if the post has a term using
has_term( $term, $taxonomy, $post );
Pass in your Term Slug, the taxonomy ( which sounds like you’re using
<?php if( has_term( 'term_slug', 'post_tag', $post ) : ?> <div> Show your div here! </div> <?php endif; ?>