Build a WordPress query to show only post within the current selected tag

  loops, php, wordpress

I am looking to build a WP query to show all post under the selected tag.

I have something working but it dose not seem to be pulling to correct post to the selected tag.

$page_tags = get_post_meta($post->ID, '_page-tags', true);

if (is_tag($tag = '')) {
$wpb_all_query = new WP_Query(array(
    'tag' => $page_tags,
    'posts_per_page' => 1,
));

}

It shows some post but not the post corresponding to the correct tag.

Source: Ask PHP

LEAVE A COMMENT