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
- 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()
- Getting wrong relationship value in $args in wp_Query?
- Check for featured image in WP_Query
- permalinks with get variables
- 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 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
- wp_enqueue_style built in styles
- 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’
- Does WordPress’s HTTP API use any caching?
- 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
- get_posts() not working when accessing with a custom user role
- ORDER BY wp_post custom column name in wp_query
- 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 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
- How to query children by post name/slug
- 400 Bad Request, in wordpress theme development, wp_ajax
- Prevent WordPress automatically processing certain URL queries
- 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
- Auto-complete or auto-suggest from stored data in database
- Get post thumbnail in WP_Query
- Pagination not working with custom wp_query
- Plugin architecture to pull from API & create dynamic content on WP site?
- Lead form that submits to 2 external APIs
- Adjust query on single
- WP_Query order posts by category
- Allow REST API Endpoint to specific user and hide from public
- 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
- How to query a nested field in wordpress api using _fields param
- 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
- Generate Static Page to Show Search Results/Detail for API
- User meta query using Wildcard
- Using AJAX to submit and return data inside the WordPress Plugin Boiler Plate framework
- Group By in a Metaquery
- WP Query date_query with several date range
- How to use information from the database in the front-end?
- Hiding WordPress REST endpoints from public viewing using Basic Authentication
- add pagination to wp_remote_get
- How do WordPress plugins work with oAuth2 APIs?
- Making Woocommerce optimized for more than 500k products
- Post Pagination does not working on WP-Query
- pull data from wordpress database
- How can I query 3 posts from diferente categories (one of each category)
- Query only title/field/featured media of posts [closed]
- API WordPress is Limited? Return False
- Custom MySQL query to pull out Advanced Custom Fields?
- Tie specific functions to options-update for limiting API requests
- post_results filter confused by pagination in sidebar and main section
- Can a plugin differentiate syndication feeds from actual site views?
- Custom query not working in plugin admin page
- Developing a plugin, ran it through P3 Profiler, shows up slow, but I don’t know why
- Can’t get query string in ajax call
- Get custom wp_query search results to appear on search.php
- add_rewrite_rule not working
- loop and in admin header problem
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- $_GET vs get_query_var()
- How to update WordPress Plugins in your own maintance application?
- Return custom product in ajax call loop
- Programmatically creating posts based on external JSON feed (asynchronously)
- A better way of getting draft posts that has a particular post meta using get_posts function