Welcome to WPSE Jason, get_posts
is for querying posts, and the tax_query
part of that allows you to select posts which belong to taxonomies of a certain criteria.
To get the taxonomy terms of a particular post, use get_the_terms
, to which you pass the post’s ID and a taxonomy. It returns an array of taxonomy term objects associated to that post, and belonging to that specified taxonomy.
Example usage:
<?php
$terms = get_the_terms( $post->ID, 'on-draught' );
//Echo a list of 'on-draught' terms for this post
echo '<ul>';
if ( $terms && ! is_wp_error( $terms ) ) :
foreach ( $terms as $term ) {
echo '<li>'.$term->name.'</li>';
}
echo '</ul>';
?>
Related Posts:
- Why Does get_posts() Return an Empty Set?
- get_posts / WP_Query Memory size of 134217728 bytes exhausted
- filter on get_posts efficiently
- Difference Between Filter and Action Hooks?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- How to create an API for my plugin?
- How to store username and password to API in wordpress option DB?
- WP_Query leaking absurd amounts of memory
- How to return only certain fields using get_posts()
- Is there a limit on making calls to WordPress.org API’s?
- Fatal error: Class ‘ms\WP_Query’ not found on plugin initialization [closed]
- Register custom query args parameter for WP_Query()
- Using filters and actions for plugin API?
- How to add multiple custom URL variables?
- Getting wrong relationship value in $args in wp_Query?
- WordPress and multithreading
- Check for featured image in WP_Query
- permalinks with get variables
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- How to ensure “the_content” filter runs only for the main displayed content?
- add_filter and remove_filter added before and after wp_query
- How to get all images and their thumbnails from wp media library
- How to create a dynamic page based on form data with a plugin?
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- Build dynamic page from cURL (HTML page) response with plugin
- Count posts returned by get_posts in external PHP script
- How to override a function call in functions.php?
- wp_enqueue_style built in styles
- Handling form request from plugin file
- Should I ask my Twitter plugin users to create their own Twitter App and API Keys to use my plugin?
- Cannot search post by taxonomy
- How to get orders with used coupon in WooCommerce
- WP_Query with tax_query, order by most ‘matches’
- Ordering posts by metadata
- Does WordPress’s HTTP API use any caching?
- How to print raw query from WP_Query class just like in CodeIgniter
- WP_Query returns no results
- Finding posts containing matching array elements in a meta field usign WP_Query
- Create a custom display order in the main menu
- manage_posts_custom_column, showing serial number using increment in loop
- Error : “Cannot use object of type WP_Post as array in”
- Proper way to run wp_query from inside a plugin
- using new WP_Query in save_post function alters $post
- Slow WP_query due to nested wp_query. Need Suggestions
- get_posts() not working when accessing with a custom user role
- ORDER BY wp_post custom column name in wp_query
- Example Dashboard Widget, Cancel not working
- How to create database table, add data, update and delete using wpdb via plugins?
- get post attachment using ajax
- Amending REST API function without deactivate/activate plugin every time changes is made
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- Why does wp_remote_post returns an empty body response on certain endpoints?
- WP_Query filters
- Adding custom end points, No error line
- Sending post request with wp_remote_post not working correctly
- How to fetch only current hour posts?
- How to get Metabox custom field to show checked if value is updated using post meta query?
- woocommerce_checkout_order_processed hook executing function twice
- WordPress pre_get_posts with combined results of two queries (OR)
- Search: how to extend the existing search to include a custom table
- How to get post content by get_posts function?
- Why does my widget break other widgets?
- how to get all the child category name in a specified category name?
- What to hook into to check a value before a post is published?
- how to invoke wordpress API from other existing PHP system
- What’s wrong with this post__not_in argument?
- How I can use order by of the custom post title?
- Delist entries in the_loop
- How to query children by post name/slug
- 400 Bad Request, in wordpress theme development, wp_ajax
- Prevent WordPress automatically processing certain URL queries
- Encoding Method for URLs?
- Store custom meta box data as serialized array
- Google credentials and redirect URI for Google OAuth2 in a WordPress plugin, questions
- how to load the comment template from a plugin
- How remove trashed WooCommerce orders from wc_get_orders() result?
- Plugin index page code executes multiple times
- Pass CF7 form data to plugin
- Best way to ping for the API changes in the wordpress?
- Auto-complete or auto-suggest from stored data in database
- Get post thumbnail in WP_Query
- Pagination not working with custom wp_query
- Get Posts by IDs (optionally)
- Plugin architecture to pull from API & create dynamic content on WP site?
- Lead form that submits to 2 external APIs
- Adjust query on single
- Widget internal hooks and functions
- WP_Query order posts by category
- Allow REST API Endpoint to specific user and hide from public
- Custom Endpoint – Does it possible to use PUT method with WP API Rest?
- Is it possible to use the MySQL’s ORDER BY FIELD() clause as part of the pre_get_posts hook?
- Get API auth_token token to renew weekly
- Multiple dynamic Tax Query – pass taxonomy argument from array
- How to query a nested field in wordpress api using _fields param
- call funcution when clicking submit
- WP_Query not ordering correctly
- How to check category name available or not
- Home page is not loading, where in other pages are displaying on the site
- how to create a shortcode from a variable in plugin
- Adding Amchart Interface to WordPress API