You might want to go through:
https://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
So using tag
parameter in WP_Query
, you can get posts tagged to ‘video’ tag.
Use orderby
and posts_per_page
to get last 5 video posts.
$query = new WP_Query( array( 'tag' => 'video', 'posts_per_page' => 5 ) );
while ($wp_query->have_posts()) : $wp_query->the_post();
//your code to display posts
endwhile;
Haven’t tested the code, so watch out for typos.
Related Posts:
- Query all posts and not repeat the same tag
- Customizing the_tags output?
- WordPress SQL query to tag all posts containing a specific word on title
- How to create an overview of posts with the same tag?
- List WordPress Post and Related Attachments outside of a post page
- Sort query_terms_list for post_tags alphabetically
- Attachment page tag queries & posts not found
- Not getting input from get_query_var
- Exclude Posts from a Widget
- Show certain number of post from tags
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- Can I create my own query in wordpress with traditional methods?
- How to Optimize WP site for millions of posts
- Get Terms by IDs with IDs order
- Using WordPress public query variables
- How many WordPress SQL Queries per page?
- Slow wp_enqueue_media()
- Advanced Custom Fields – Query Efficiency
- How to display lastest post date in the homepage?
- $query->query_var[‘post_type’] not set for pages
- How to tell if $query_var isset?
- Sorting Grids with Essential Grid and Events Manger
- The use of including upgrade.php when building custom queries
- Get the timout value of a saved transient?
- Does meta_query work within get_posts array?
- Slow meta_query with about 4 milion record on wp_postmeta
- How to show more than 5 posts?
- WordPress Find Duplicate Post By Content
- How many queries are normal to execute on a WP site?
- WP Query Sort by meta value (date)
- How to optimize my query filtering out unwanted data?
- mySQL query. ORDER BY meta_key
- Remove posts from query for events whose start date has passed
- how to query multiple categories in wordpress?
- Disable the MySQL query in the main query
- Strange string in console from wpdb query
- Update slug (URL) of pending posts via phpMyAdmin
- How can I get the query that would be run for the archive page?
- Error when using setup_postdata()
- Query metas (and not : query posts by metas)
- Select query for a login
- What’s wrong with my $wpdb prepare?
- where should I reset query after using get_results?
- Getting post data from private page
- Exclude featured image and custom field from this get_attachment query
- SQL query to select posts from multiple categories
- I can ‘t display product images based on the label
- Query posts intersecting tags and categories
- Select Query demand excesive resources [closed]
- wpdb print all post meta
- Form and custom query problem
- Export Specific User data without plugin
- How to write: $wpdb->update having WHERE NOT value pair in the array
- Exclude categories from the_category();
- How can i show all categories using wp query?
- Exclude all sticky posts front page twenty twelve
- wpdb COALESCE won’t work
- get csv of users with user_meta
- Custom SQL Query passing array to WHERE p.id
- Query does not return content
- Query posts dynamic date range
- How to read the value of a WordPress $query associative array (hash) key
- Parse query filter in wordpress and relation
- Query posts based on previous query
- Querying with WP query using meta key price
- Re-sort get_posts query results
- How do I get all results from my query
- Taxonomy filter under Polylang
- WordPress Mysql query and Duplicate
- create a link to a random post within the current category
- How to “orderby” the first array in a meta_query that uses multiply keys?
- Pagination not working on custom post types with rewrite slug
- JetEngine Query Builder – order by value from repeater
- Change pure SQL database query to WordPress post query?
- how to add tags to post in the Loop?
- Filter orders by modify date
- How to add url parameter to every search query in SearchWp?
- Order posts ascending from posts in array
- Display data from phpMyAdmin with WordPress
- Heavy meta query causing SQL crash
- Sort by postmeta on when searching
- Pulling an ACF into a query
- Speed up search query that searches in post meta?
- Category_in return empty
- modifying main query to query for ranges e.g. from 1999 to 2016
- Querying users by meta value and getting a strange answer
- Using cron for multiple queries
- very slow wordpress query with default query
- Custom Query problem access the values
- Set posts per page for parent category and it’s all children
- Exclude sticky posts from query
- How do I add tags/taxonomy to images + a query field on page to query ‘albums’ (images with same tag/taxonomy)
- If more than 1 image show post link?
- Rewrite Query_Var URL Parameter with Slug
- How to query different categories on index?
- How to specify what kind of is_single post?
- Can’t See Media Queries with Inspect Tool [closed]
- Print data from wordpress sql query
- What is the best way to cache pages and queries in WordPress?
- How to figure out correct wp_options to have autoload=’yes’