I usually use the tax_query parameter:
$args = array(
'post_type' => 'my_cpt_name',
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array( array(
'taxonomy' => 'uom_system',
'field' => 'slug',
'terms' => 'metric-system'
) )
);
$results = get_posts( $args );
See http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
Related Posts:
- Strategy On Building Plugin Using Eclipse
- WordPress as College Application System (Embark)
- Is It Always a Best Practice to Decouple the Frontend from the Admin Area When Developing a WordPress Application?
- Get Current Menu Location inside Nav_Walker
- How should I go about registering JavaScript that isn’t a file? [duplicate]
- How can I start Plugin Development?
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- How can I add an image upload field directly to a custom write panel?
- Creating a table in the admin-style?
- What process do you use for WordPress development? [closed]
- How do I create a custom role capability?
- What is the advantage of using wp_mail?
- Plugin Form Submission Best Practice
- How to return only certain fields using get_posts()
- Where to put third party PHP library?
- Add a new tab to WordPress Plugin install Listing
- Export data as CSV in back end with proper HTTP headers
- Plugin directory “Last Updated” not changed after initial commit?
- Scheduled events disappear from events queue
- How to integrate a PHP webmail script into the backend of WordPress?
- Calling the widget id of a mult-instance widget from inside the widget?
- What is the recommended way to create plugin administration forms?
- How to log plugin errors to plugin error_log file
- Custom Post Type Link from Plugin
- How to Get a List of Sub Blogs without Using get_blog_list()?
- Do I need to call do_action in my plugin?
- Fatal error: Call to undefined function wp_mail()
- Does WordPress have an Browser Agent?
- How Do I Load My Action Earlier Enough?
- How to check WordPress website username and password is correct
- Using wp_cron with custom time interval and the register activation hook
- Conditional check to see if a bootstrap.css is included in a theme
- WooCommerce get Shipping Class of product from either the product id or the order after order is completed
- Throw 403 in a plugin [duplicate]
- WordPress multisite apply different options over each site from same plugin
- Using ob_start() in plugin
- Dequeue script, but still use wp_localize_script to pass vars
- I can’t find where a hook is being defined in a plugin – Easy Digital Downloads
- Filter on the_content ignores shortcodes
- Custom theme sufficient or custom plugin neccessary for this feature set?
- Create Element From Dynamic HTML String [closed]
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- Check spam in custom form – akismet
- How can I view all WP generated thumbnails in Media Manager?
- Only allow plugin to be activated on root site of multisite
- what is the best practice for including ‘wp-includes’ classes
- Programmatically Selecting Theme Based on URL
- get plugin directory url
- Custom Plugin Database relations
- Save user-specific options in WordPress admin
- Why is print_r returning $classObj->userObj in several places on site
- Is it possible to load plugin from console with core ?
- WordPress cron running twice
- How can i get the title i specified in add_options_page for my header
- use __($str) to translate strings (symfony/twig)
- Plugin development: is adding empty index.php files necessary?
- Plugin base URL
- Database for development
- PHP library that can merge stylesheet with inline style [closed]
- Is there a way to list tags order by post_meta field
- how to redirect to another post without getting headers already sent error?
- Customize multisite site creation with user data
- admin_notices not displaying in plugin
- Adding plugin settings link upon activation
- How to create multiple Gutenberg blocks in one plugin
- How to disable reCaptcha v3 except on Contact Form 7 pages?
- How to get color name in PanelColorSettings in custom Gutenberg block?
- Get Objects While Deleting term
- Change template dynamically
- add a class when login
- Fetching the value of forms in WordPress AJAX
- Cannot redeclare function error on the same line
- js/css updating when making a plugin
- Proper way to run wp_query from inside a plugin
- Programmatically detect if wp-cron is disabled?
- Buddypress function and global $bp question
- Custom plugin: Loop through taxonomy types and update columns for all types?
- How to add setting section in custom post type [closed]
- Append country to ‘pretty’ url but serve same page
- Widget is to be compatible with all themes
- How to create a table with filters for my plugin
- Maximum lifetime for nonce
- How to Display my HTML form in my Custom Plugin?
- Where to add hooks in a class
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Adding a brand column to WooCommerce Products
- Custom GET Parameters In Plugin’s Admin Page
- Adding option to Gallery shortcode
- WordPress Search filter to remove possible script injections
- wp_insert_user() function password never match
- How to setAttributes in Gutenberg block?
- Adding rewrite rule dynamically
- Mixing and Matching – Custom templates in a WordPress plugin
- Prevent third party plugin’s admin page access based on user type
- Incorporate small angular feature in my wordpress site
- Bootstrap doesn’t work on admin menu page-How to override wp-admin style?
- Open Graph Object Debugger & url parameters – Page Not Found result
- Use just a shortcode from another page
- I have 2 plugins using the same wp_login action hook and one is not working