Skip to main content

I need to do a wp query that will get any post that has one tag or more. My current code workworks for one tag, but I've try for multiple with the codex and I can't do.. it. can Can you help me  ? Thank's !

<?php
global $post;
foreach(get_the_tags($post->ID) as $tag) {
} 

$recent_posts = new WP_Query(array(
    'cat'  => 20,
    'tag_slug__in' => $tag->name . ', ',
    'showposts' => 2
));
?>

I need to do a wp query that will get any post that has one tag or more. My current code work for one tag, but I've try for multiple with the codex and I can't do... can you help me  ? Thank's !

<?php
global $post;
foreach(get_the_tags($post->ID) as $tag) {
}
$recent_posts = new WP_Query(array(
'cat'  => 20,
'tag_slug__in' => $tag->name . ', ',
'showposts' => 2
));
?>

I need to do a wp query that will get any post that has one tag or more. My current code works for one tag, but I've try for multiple with the codex and I can't do it. Can you help me?

<?php
global $post;
foreach(get_the_tags($post->ID) as $tag) {
} 

$recent_posts = new WP_Query(array(
    'cat'  => 20,
    'tag_slug__in' => $tag->name . ', ',
    'showposts' => 2
));
?>
Source Link
newo1t
  • 1
  • 1
  • 1

WP Query with multiple tags by get the tags

I need to do a wp query that will get any post that has one tag or more. My current code work for one tag, but I've try for multiple with the codex and I can't do... can you help me ? Thank's !

<?php
global $post;
foreach(get_the_tags($post->ID) as $tag) {
}
$recent_posts = new WP_Query(array(
'cat'  => 20,
'tag_slug__in' => $tag->name . ', ',
'showposts' => 2
));
?>