Articles of tax query

Function using get_posts() with tax_query not working when called from functions.php

I want to get an array of all the ‘bands’ in taxonomy ‘types’, and use the array later on in other functions etc. I have a utilities.php file that I require() in functions.php and it has the following function definition and a call to it right after: function get_all_bands() { $bands = get_posts(array( ‘post_type’ => […]

Running a custom query inside another cpt single and trying to grab a variable

I made a cpt “Neighborhoods” for different neighborhoods. On the Neighborhoods archive, you click on one and go to the single. All good. an example url is /blog/neighborhoods/south-austin/ But I’m trying to run a wp_query on that single looking for all properties in that are in that neighborhood. I created a custom taxonomy called “prop_neighborhood” […]

How to restrict search on a certain page to only return results against custom taxonomies?

On a specific page, I would like the search to be performed only against the terms from two custom taxonomies. Not the content or title. That is, the user is directly searching taxonomy terms. What I’m trying to do is completely rewrite the query for searches, but it doesn’t seem to work. function search_filter_get_posts($query) { […]

How to extend tag and category “Related Posts” query to custom post_type if the first 2 terms have no posts

Scenario I am using a complex, awesomely crafted tax query to get up to 4 related posts, first going by tag, then by category if there are not enough posts in tag-related query. This was finely addressed here. I am now trying to do another extension of this function to do a 3rd query when […]

tax query shortcode

Configuring my shortcode with tax query is proving dificult. When i omit the params for taxonomy/terms i get nothing back. This returns 1 post back as expected [loop post_type=”website” taxonomy=”industry” terms=”beauty” posts=”3″][/loop] But when omitted params for taxonomy it returns no posts when i want to get all the website posts back. [loop post_type=”website” posts=”-1″ […]

Get term by custom term meta and taxonomy

How to get term by custom term meta and taxonomy or how to filter tax_query by term meta instead slug/id? function custom_pre_get_posts($query) { global $wp_query; if ( !is_admin() && is_shop() && $query->is_main_query() && is_post_type_archive( “product” )) { $term = ???get_term_by_meta_and_taxonomy???(‘custom_meta_term’,’my_taxonomy’); $t_id = $term[‘term_id’]; $tax_query = array ( array ( ‘taxonomy’ => ‘my_taxoomy’, ‘field’ => ‘id’, […]

Count number of posts which exist in 2 taxonomies?

I know I can use something like this to count for ONE tax: $catcount=get_term_by(‘slug’,’apple’, ‘FRUIT’); echo $catcount->count; but not sure how to count posts that are in combos between taxonomies… I have two custom taxonomies, and I want to count the number of posts (custom post types, actually) that are in each pair match between […]

tax_query: Order by slug?

Long story short, I inherited a WordPress site at work and I have an events page that I’m working on/fixing. I’m new to both WordPress and php and I could use some help. Each event is categorized by school semester (Spring, Summer, Fall). However, I cannot get the semesters to order anything other than alphabetically […]

How to do a particular wp_query taxonomy search

I have added a custom taxonomy called experience to the page post-type, and the taxonomy has terms “vfds” and “plcs“ I am trying to create a search where a user can select one or more experience taxonomy terms from a select list, press the submit button, and see the results of a wp_query. I need […]

WP_Query parameter conflict

I am writing a query to retrieve instances of a custom post type I created called “Specialist”. In the query I specify a name and more than one taxonomy. I want to retrieve just those specialist which respect both parameters. If I run the two queries separately, the correct specialists are returned but when I […]