WP 5.8 “Query Loop” block: where to place custom query?

In the recent wordpress.org article outlining the new Query Loop block, it says the “Inherit query from template” option allows you to “customize the query that the loop relies upon … WordPress will otherwise rely on the template being used to determine what posts appear”. There appears to be no further guidance on this. What … Read more

Exclude from search all custom posts which are NOT in a taxonomy term

I have a custom post with a taxonomy associated to it. That taxonomy only has one term, and posts either belong to it or not, in a boolean fashion. On the search results, I wish to show the custom posts that belong to the taxonomy, and not show the ones that don’t belong. I’ve thought … Read more

SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement

Working on a tool outside of WordPress to query the wordpress database by POST_ID and return the Category Name associated. This is for a real estate website, and the Categories are called “mi_neighborhoods” and are referred to by wp_term_taxonomy.taxonomy. In one of my other queries to get all the Category names I use: SELECT * … Read more

wp_get_object_terms() to get a list of all the terms attached to all the posts in the current query

How can I use wp_get_object_terms() to get a list of all the terms attached to all posts in the current query? For example, for the current query I want to get an array of the terms from the “Alfa” taxonomy that are contained in all the queried posts. wp_get_object_terms($wp_query, ‘alfa’); But that only seems to … Read more

Is it possible to add custom fields to a WooCommerce attribute term? [closed]

Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for WordPress Development Stack Exchange. Closed 3 years ago. Improve this question On WordPress / WooCommerce, is it possible to add custom fields to a WooCommerce attribute term? With “attributes” I mean the … Read more

How to modify the query in taxonomy-custom.php to sort term archives by a custom meta field?

I am trying to create theme pages for custom taxonomy terms in which the archives are ordered by a custom meta field. I can do this with a new wp_query as follows: <?php $directory_archive_query = new WP_Query( array( ‘post_type’ => ‘directory’, ‘posts_per_page’ => 200, ‘meta_key’ => ‘surname’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’ ) ); … Read more

Assign posts to taxonomy terms instead of the taxonomy terms to posts?

So I have a custom post type (people) with a related custom taxonomy (directory). Instead of editing a person and then choosing the related directory organizations I’d like to “edit” a directory org and choose the people that belong to it. Anyone know of a plugin that allows this? I could build my own plugin … Read more

Using multiple taxonomies to sort Custom Posts

I have a post type that includes a taxonomy for (1) location and (2) a day of the week. I’m using the first taxonomy to sort the posts into groups. Here’s the loop I’m using: <?php $terms = get_terms(‘cell-locations’); $argv = array( ‘orderby’ => ‘by_term’, ‘hide_empty’ => false ); foreach ($terms as $term) { $wpq … Read more

How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy

This answer provides the code for a query that returns an OR match on a taxonomy term: global $query_string; $args[‘tax_query’] = array( array( ‘taxonomy’ => ‘status’ ,’terms’ => array( ‘available’, ‘pending’ ) // change to “sold” for 2nd query ,’field’ => ‘slug’ ), ); I’d like to have my taxonomy template retrieve the term values … Read more

Custom Taxonomy and Tax_Query

I’ve been having a lot of trouble getting a WP_Query running with a tax_query on my custom taxonomy. I’m 99.9% sure that my register_taxonomy is correct, as I’m able to tag posts with the right term, see it in the database, and the correct term returns with this function: http://pastebin.com/18Aj1ysT . But when I use … Read more