For testing purposes in your functions.php
file, try this –
add_action('init', 'my_test_get_all_bands', 99);
function my_test_get_all_bands(){
echo '<pre>'; print_r(get_all_bands()); echo '<pre>';
}
As I was attempting to say in my comment to your question (and as Pieter Goosen explained rather better), if your taxonomies have not yet been registered then the tax_query
portion of your get_all_bands()
function will not work as the taxonomy types
does not exist.
I don’t know exactly how you are adding the taxonomy, but personally I use the init
hook with a priority of 1
, and that is why I’ve used a priority of 99
in this example.
The long and short of it though is that your function works, you’ve proved that by using it in your templates 🙂
Hope that helps.
Related Posts:
- WP_Query vs get_posts
- get_template_part in for loop
- How-to exclude terms from the main query the most performant way?
- get_posts() seemingly ignoring post_type
- WP_Query, tax_query and term_meta: How to?
- Get posts for last working week in WP_Query
- Conflict with get_posts and the_content
- Best choice for multiple loop in page?
- get_posts output always same post
- How to add tax_query to $args with concatenation
- Loop posts based on permalink term
- How to access $wp_query object from array of posts given by get_posts?
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Facing problem with tax_query results
- Populate select list with meta values from all posts of a Custom Post Type
- Related posts queries
- Ordering Posts by parent category, name ascending
- Both WP_Query and get_posts returning 1 post
- Output ACF field dynamicaly within a taxonomy loop [closed]
- tax_query not working properly with get_posts
- Custom query for certain post type OR another post type with a certain category
- Can I force WP_Query to return no results?
- Multiple WP_Query loops with Pagination
- WP_Query and next_posts_link
- Sanitation needed for WP_Query or get_posts calls?
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Use of caller_ get_ posts
- Tax_query terms ID’s using variable
- Get array of posts from the current archive page loop
- How can I save an array from a random post sequence for later use?
- Meta Query with date and time on the same Day before given time
- In loop: posts have thumbnail AND other variables
- Get posts with condition on comment meta value
- How to order category.php loop by ‘meta_value’?
- Add inline HTML to posts published within last 24hrs
- Move posts to top of WP_Query if in certain Taxonomy?
- What should I use, get_posts or wp_query for less CPU load?
- Display different number of posts from one category on the different pages
- Pagination not working Search posts
- How to extend tag and category “Related Posts” query to custom post_type if the first 2 terms have no posts
- Can certain (site-crashing) limitations on WP_Query in shortcode be overcome?
- wordpress query in header won’t reset and corrupts other loops
- Change default ordering of taxonomy terms – pre_get_terms
- Implementing an OR statement to wordpress wp_query
- Get List of all the Authors
- How can i simulate “taxonomy__in” in query?
- WP_Query loop within WP_Query loop
- Refine search results using WP_Query
- How to pass many ids in post__in?
- How to show subcategories using loop?
- Sub-loop / nested loops Best Practices
- Populate tax_query terms parameter with post term
- Show Sticky Post at the top but do not show again in the loop?
- Any number in meta key (wp query)
- How do I run through a WordPress loop called from a filter function?
- How do I get the title of a category in a custom loop?
- Fastest way of counting posts of a custom post type in a specific taxonomy term?
- Is it a good idea to improve meta query performance by adding tax query?
- WP_Query | Tax_Query Relation | Unable to use ‘OR’ as it then allows all products, help me finish my query?
- Out Of memory issue on post per page parameter
- Check if loop has any categories?
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- How to count posts with specific arguments
- Change query from cat id to slug or name?
- Using Wp_Query without the loop?
- Custom WP_Query id
- Assign custom parameter to each post in query
- complex get_posts() query to select child pages
- AJAX Breaking Offset Argument In WP Query
- How does WP generate the default $query in WP_Query based on the URL?
- How to print term name inside wp post loop
- how to get category`s slug in WP_Query loop?
- How to remove only the latest sticky post from the loop
- How I can repeat 2 HTML templates in a WordPress Query?
- Search for pages with permalink
- Query Not working as expected
- Show multiple tax_query from 2 or more post_type in a single code
- How to make the ‘request’ filter work?
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- How do I stop the same post showing multiple times in a archive?
- How to get meta key list efficiently?
- Why pagination is not working with tax_query param?
- how to get custom attachment url?
- how to get wp_query posts only first letter of alphabet A?
- WP_Query & Duplicate entries
- Query child posts with tax query on parents
- Calling a function with WP_Query only ever brings the first result
- query_posts() doesn’t seem to be called in my page
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Why WP_Query in functions.php is not working when get_posts works?
- Next / previous posts link doesn’t show up with Posts 2 Posts
- Query specific number of posts for each post type in specific order
- Carousel Loop only duplicating
- Remove 5 latest posts from the loop
- How to show featured post first, then separate loop for other posts
- posts_per_page – Repeats only first posts ‘post__in’ array
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Pagination only showed when no category is set in wp_query
- Sort by multiple columns using get_posts