I think showposts was replaced by posts_per_page in wordpress 2.1. See pagination parameters. Also note that print_r($query) won’t return any results because $query variables is WP_Query object; you need to exceute the query.
$args = array(
'post_type' => 'contractors',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'terms' => $taxarray,
'field' => 'id'
)
)
);
$query = new WP_Query($args);
$results = $query->get_posts();
print_r($results);
Related Posts:
- Taxonomy: Why ‘with_front’ => false DOES NOT WORK?
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- Assign posts to taxonomy terms instead of the taxonomy terms to posts?
- Exclude from search all custom posts which are NOT in a taxonomy term
- Custom SQL Query on Custom Post Type. Order by Taxonomy?
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- Paginated Taxonomy Term Archive including one post per term
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- Get posts by querying taxonomy and certain terms of the taxonomy?
- Custom post type templating problem
- Custom Post Type Taxonomy Filters
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- How to conditionally redirect to the post from a taxonomy page?
- How to group posts and get a mixed posts and groups view?
- How to list tags from custom post type attachments?
- How to get_term_meta on single custom post?
- I have custom post type with custom taxonomy. But not found the taxonomy page..
- How to List Custom Post Type Titles Based on Theirs Taxonomy Terms Inside a Nested Loop
- Single.php for Custom Post Type > Taxonomy > Term
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- ACF – Retrieve custom taxonomy from a relationship field
- Display Custom Field or Custom Taxonomy in front page /post/product
- WP_Query not using custom taxonomy categories on custom post type
- Showing taxonomies with terms that are attached to custom post
- Getting all custom post taxonomies and exhibiting only part of them
- Error get_posts with Custom Taxonomy and OR relation
- Get list of CPT posts in *current* post’s taxonomy term
- tax_query showing no results
- Linking custom taxonomies and posts
- Storing/querying custom date data
- Taxonomy, Terms, and Template Files
- Exclude a category from WP_Query
- Check if post type has term
- How do I Filter Custom Post Type by Custom Taxonomy in the newest WordPress RESTful API?
- Changing the priority of a custom taxonomy’s metabox
- How to list all categories and tags in a page?
- WordPress custom taxonomy URL rewrite on spelling errors
- TV Show database – Best way for structuring it?
- Many to Many Taxonomies or rewrite rules?
- Query posts by custom post type and custom taxonomy
- Sort the main query in subcategories/terms?
- How to display the rest of categories on Portfolio filterable
- Highlight nav menu terms
- Custom Post Types, Custom Taxonomies and Permalinks ?
- How to query custom post type by term?
- How to get the first term for the current taxonomy?
- removing custom tax & CPT slug, adding taxonomy term in front of custom type
- Custom Post Types relationships
- Display Posts in Custom Post Types Timber
- How can i skip same post from taxonomy term?
- Getting a PHP Notice when using Pods with WPML [closed]
- Custom post type multiple loop by taxonomy term
- Extending AZIndex plugin to use custom post types and custom taxonomies
- How to display custom taxonomies with links in filter menu?
- List custom taxonomy specific to one custom post type
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- How to Filter custom post type by taxonomy?
- What’s the WP way to load remaining custom posts?
- Search by tag name and category
- Query posts with double taxonomy
- get_the_title() is returning results from previous loop
- Creating two loops based on different logic
- get_category_link() for custom post type does not include custom slug rewrite?
- How to show all taxonomies within custom post type loop
- Custom Search | check multiple meta_value for search value
- Using WP_Query, I want to show posts that are associated with a custom taxonomy term
- Foreach loop returning more than one item when querying taxonomy
- Check when the post type changes, and display content
- custom post archive URL is wrong
- In child theme, add CPT to custom taxonomy registered in parent theme
- Custom taxonomies not displaying in some custom posts
- Static Front Page not working for custom theme
- WP_Query to display number of custom post type filtered (order by) taxonomy
- Live search by custom tag
- Set a Default CPT taxonomy by taxonomy id
- Custom taxonomy terms registered not showing when added in child theme
- Custom post edit page permalink links to edit page rather than the post
- Not Able to List CPT Based on Taxonomy Term
- Display all Custom taxonomy terms and their relevant custom posts
- Best way to group posts based on custom post type terms
- Render custom taxonomy query as single template
- Custom meta-box for all custom post types
- Remove custom taxonomy ‘post-type’ from post URL
- Custom My account page and custom page for editing posts
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Require Custom Taxonomy for Custom Type
- Custom Post Type urls not working
- pre_get_posts causes Custom Posts appear under ‘Pages’ menu
- Show custom category archive as front page and remove taxonomy slug from urls
- Create a hierarchical list of posts that’s grouped and nested by category
- Show a wordpress custom post condtionally using a category term
- Categorizing Custom Posts in Bulk Based on Title
- Remove prefix from custom post type archive page
- WP_Query not using relation key as expected and not producing any results
- How to get the proper category in permalink with custom post type assigned to multiple categories
- How to Connect my Users to a custom post type I Labelled Campaign
- Custom fields disappearing when a custom post type is assigned
- Search for portfolio tags & mixing portfoliotags and post tags
- Add body class to custom post type
- Is there a way to edit non-custom term attributes?