Querying on multiple taxonomies pulled from $_GET checkbox array not working?

Here: $search_values[‘tax_query’] = array ( You’re resetting the value of tax_query for every item in the foreach loop. It’s also being set to an invalid value: Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays). This construct allows you to query multiple taxonomies by using the relation … Read more

I have 2 post types i need to show the post type contents in 2 select boxes [closed]

Below Code will generate Select box of post type “resources” change this value as per your post type. <select name=”page_id” id=”page_id” class=”archive-dropdown” onchange=”document.location.href=this.options[this.selectedIndex].value;”> <option value=””>Select Resource Post</option> <?php global $post; $args = array( ‘numberposts’ => -1,’post_type’=>’resources’); $posts = get_posts($args); foreach( $posts as $post ) : setup_postdata($post); ?> <option value=”<? echo get_permalink($post->ID); ?>”><?php the_title(); ?></option> <?php … Read more

Get taxonomy parent using child slug (from merged taxonomies)

Since in most cases I would need to now the ‘taxonomy’, one work around I found (actually, pointe by @Howdy_McGee) was to pass the slug of the term and it’s parent to the value, and then split-string. Here is my final code: foreach ($tax_categorias as $tax_categoria) { echo ‘<option value=”. $tax_categoria->slug .”.’. $tax_categoria->taxonomy .” . … Read more

How to display product subcategories into my custom post type single page

Using wp_list_pluck to return an array in the form of array(term_id => parent, …), you can do the following (explanation is given in the comments): $variations = get_the_terms( the_ID() , ‘product_cat’ ); if(is_array($variations)) { //make sure terms were returned $parents = wp_list_pluck( $variations, ‘parent’, ‘term_id’ ); foreach ($variations as $variation) { if($variation->parent && $parents[$variation->parent] && … Read more

How Can I Change a Taxonomy URL Based On The Originating URL?

The term_link filter has a different signature for its callback function than the page_link filter, meaning the arguments in your callback are different. (Also note you’ll need to explicitly set the argument number when you call add_filter because by default add_filter will only setup 1 argument. For example: add_filter( ‘term_link’, ‘lqd_series_link’, 10, 3 ); // … Read more

Order posts by taxonomy count

this topic might help you. By default args of WP_Query – this is impossible. I don’t think you can do that directly. Although you can save terms count for each post in a custom meta field (on post publish) and then in your query define sort by that meta field. Or while running your query, … Read more

get_object_taxonomies() returns empty array for custom post type

I have run into the same issue. I believe the root cause is the order of execution. For the sake of experiment, I ran get_object_taxonomies() immediately after register_taxonomy(), in fact in the same function and it worked as expected. So what to do? Use add_action() hook to execute get_object_taxonomies() after register_taxonomy(). The correct order of … Read more

Custom taxonomy in custom post RSS feed

You can hook into the request filter and set the post types to whatever you wish: add_filter( ‘request’, ‘cpt_in_rss’ ); function cpt_in_rss( $request ) { if ( isset( $request[‘feed’] ) && ! isset( $request[‘post_type’] ) ) { $request[‘post_type’] = [ ‘post’, ‘cpt1’, ‘cpt2′ ]; } return $request; } Here’s a trac ticket about what you … Read more