W
W
Web Lizard2016-03-25 19:33:11
WordPress
Web Lizard, 2016-03-25 19:33:11

How to make get_posts() display posts by tag?

Is there any way to display posts by tag using get_posts()?
I tried like this but it doesn't work

$tag = single_tag_title('', false);
$product_list = get_posts("tag=$tag");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2016-03-25
@Lizard-108

https://codex.wordpress.org/Template_Tags/get_post...
https://codex.wordpress.org/Class_Reference/WP_Que...
https://codex.wordpress.org/Class_Reference/WP_Que...
Specify not title and slug. Well, or ID. And the single_tag_title() function returns title, that is, the title.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question