I'm trying to echo one of the tags the posts has. There are multiple tags, around 40.
Currently I'm trying:
<?php
$tag = get_tag(16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58);
echo $tag->name;
?>
Edit:
function misha_filter_function(){
$args = array(
'orderby' => 'date', // we will sort posts by date
'order' => $_POST['date'] // ASC или DESC
);
$args = array(
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'post_tag',
'field' => $cat_id,
'terms' => $_POST['locationfilter'],
),
)
);
$relation = 'AND';
if( isset( $_POST['timefilter'] ) )
$args['tax_query'] = array(
'relation' => $relation,
array(
'taxonomy' => 'post_tag',
'field' => $tag_id,
'terms' => $_POST['timefilter']
),
);
$query = new WP_Query( $args );
if( $query->have_posts() ) :
while( $query->have_posts() ): $query->the_post(); ?>
<!-- post -->
<a href="<?php the_permalink()?>">
<div class="col-md-3 col-sm-6 ver-item">
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<div class="thumb" style="background-image:url('<?php echo $thumb['0'];?>');"></div>
<section>
<time>
<!-- here is where the tag should be displayed -->
<?php $post_tags = get_the_tags('YOUR POST ID');
if ( $post_tags ) {
echo $post_tags[0]->name;
}?>
</time>
<h3><?php the_title();?></h3>
<span><!-- underline --></span>
</section>
</div>
</a>
<?php endwhile;
wp_reset_postdata(); else :
echo 'Geen resultaten, probeer het opnieuw.';
endif;
die();
But the problem with this is that it only outputs the first tag on all posts. That's the tag with the id 16. It even echo's the tag-id 16 to other posts, which don't even have that tag.
How can I echo only one the tags, if the posts has that tag/has one of those tag-ids?