Get Posts based on Tag…
-
I’m passing variables to a Page via URL, ex: url.com/team?grade=2018
I then want to use that value to get posts with the tag 2018 so that page will show related posts. As I look at the get_posts template tag, I don’t see where I can note just to get Posts relative to what Tag they have.
$args = array(
‘posts_per_page’ => 5,
‘offset’ => 0,
‘category’ => ”,
‘category_name’ => ”,
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
‘include’ => ”,
‘exclude’ => ”,
‘meta_key’ => ”,
‘meta_value’ => ”,
‘post_type’ => ‘post’,
‘post_mime_type’ => ”,
‘post_parent’ => ”,
‘author’ => ”,
‘author_name’ => ”,
‘post_status’ => ‘publish’,
‘suppress_filters’ => true
);
$posts_array = get_posts( $args );I can’t really use a plugin because I need it to be dynamic based on the variable passed by the URL.
- The topic ‘Get Posts based on Tag…’ is closed to new replies.