I would recommend becoming intimately familiar with the WP_Query parameters:
https://developer.wordpress.org/reference/classes/wp_query/
In your particular case; dealing with taxonomies:
https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters
Here is the proper code to pull from a taxonomy:
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'units',
'field' => 'slug',
'terms' => $term->slug
),
),
);
$query = new WP_Query( $args );
The taxonomy
should be the slug of your registered taxonomy. In this case, I’m assuming units
.
Related Posts:
- Order get_terms using a Custom Field
- Get value in custom field with taxonomy [closed]
- Remove Category description textarea
- Custom Taxonomy Images with Advanced Custom Fields
- Advanced custom fields – taxonomy terms images [closed]
- Displaying ACF image field [closed]
- Operations with custom fields values in a loop
- ACF vs Taxonomies
- Specifying a size when displaying an image associated with a taxonomy through ACF
- How to add contents of a custom field to a taxonomy term list?
- Search Tool only refreshes Page without showing results
- Display value of custom field of custom taxonomy in single post?
- How to fetch the data from Advanced Custom post when we search specific keyword or field name related to the post?
- WordPress implode & wp_insert_post question
- Website loading slowly – Advanced Custom Fields images
- Display a colour of custom taxonomy on the page
- Can’t get taxonomy ID for each post on archive page
- Loop to display ONLY custom taxonomy parent information [closed]
- Using Advanced Custom Fields Relationship Field to select a taxonomy term
- query to use to link to taxonomy single page
- Show related posts on single.php, grouped by taxonomy terms, with Advanced Custom Field post object selected
- Why do my quick edits for custom taxonomies not show on the post frontend?
- Echo ACF taxonomy field within a foreach for another taxonomy
- new custom filed not showing in taxonomy
- Connect ACF field + custom taxonomy [closed]
- Adding Advanced Custom Fields to posts
- ACF Field, hide taxonomy title and image when no nothing selected in post
- ACF Custom field not showing in Timber Taxonomy page
- WordPress search form and search result through ACF field in custom taxonomy
- How to show selected check box vendors on front end home page?
- Creating a list with multiple categoreis and options
- Taxonomies, Adanced Custom Fields and Repeatable Fields
- ACF Display Taxonomy Image Field
- Gravity Forms with Advanced Post Creation Add-On not updating ACF fields on custom taxonomy
- Get term name from term ID?
- Contact Form 7 – Populate Select List With Taxonomy [closed]
- Front End Post Save Child terms
- URL rewrite rules for multiple taxonomies query
- Page queried instead of a custom taxonomy
- Pros and cons of using [taxonomy name] in place of [category name]?
- How to display and use all existing tags at my write-post-at-frontend-panel?
- How to use create_term, edit_term, delete_term actions?
- drop-down list another query
- Echo taxonomy term meta on author.php
- Hierarchical display of custom taxonomy
- custom taxonomy archive permalink shows 404 error
- is there any limit of length on creating custom taxonomies?
- How to get a list of taxonomy terms which are being used only within certain post types?
- Taxonomies: display hierarchical parent list
- Display an image instead of tag name?
- Custom fields ‘for’ custom taxonomy?? Can someone explain why?
- List taxonomies according to whether this post is in another taxonomy in taxonomy archive
- Create and set templates for custom taxonomies
- Taxonomy template shows only 10 posts
- Pagination on custom taxonomy
- Register a pre defined tree of taxonomies
- Disabling wp_tag_cloud() outputting inline CSS
- How to show all possible parents and children of a hierarchical taxonomy term?
- Custom Taxonomy
- How to use taxonomy term as a value of get_template_part?
- querying posts by custom taxonomy terms right from a querystring based URL
- How to change url for taxonomy pages?
- Take a custom taxonomy value and save as a standard Product Tag
- Check If Taxonomy A and Taxonomy B has same Slug, 301 Auto Redirect Tax A to Tax B if True in WordPress
- wp_dropdown_categories – how to save in widget?
- echo a specific custom taxonomy term on a different custom taxonomy archive
- Loop through custom taxanomy in post and display custom fields from posts
- query_posts that have custom taxonomy and limiting what shows based on the taxonomy
- list custom taxonomy with count
- Custom Taxonomy List with Children
- Dynamically generate category id and store in variable
- saving custom taxonomy as post title
- Taxonomy list links to first post in that term
- Extra Meta Data for WordPress Multisite Taxonomy
- Problem with sorting in custom child taxonomy archive page
- Check if any available product has specific attribute
- Tax-query on taxonomy doesn´t work
- How to Create taxonomy using ‘null’ for $object_type?
- how can i add more than one custom taxonomy?
- Query Multiple Taxonomies and Multiple Terms with Different Operators
- Pre_get_post custom taxonomy combined with custom fields?
- Adding a checkbox field to a (custom) taxonomy
- Country-specific content
- Ignore punctuation marks in taxonomy order by name
- Echo custom taxonomy values
- Resize $term attachment using url
- Product dimensions filter by taxonomy
- How can I pull the slug of a custom taxonomy and output it in a class?
- Custom taxonomy escaping html attr
- Showing list of custom posts of a custom taxonomy
- Multisite custom taxonomy archive issues
- How to show/hide a meta box using categories, with a different post type
- Producing a list of media library items categorized under a certain taxonomy item
- Use custom field as tag slug
- How To Display Selected Terms For Custom Taxonomy?
- Custom taxonomy subcategories template page
- Adding a query var to taxonomy term archive – gets redirected to the other taxonomy archive page
- $term->taxonomy stripping out underscores
- Custom Taxonomy, shows empty value (home page of website)
- Custom taxonomy archive templates not found