Retrieve Custom Taxonomies according to posts selected

The loop for $listings should include a call to $listings->the_post() so that the global post object is assigned to the current listing in the loop: while ( $listings->have_posts() ) { /*** Add the following line: ***/ $listings->the_post(); $post_get = get_the_ID(); $term_get = get_the_terms($post_get, ‘Car_Series’); $term_array = $term_get; print_r($term_get); array_push( $term_array, $term_get); } Without this, functions … Read more

Querying two taxonomies

This helper function will return the ID of the term you are currently viewing (from any taxonomy – you can limit just to a specific taxonomy, or the built-in tag and category taxonomies). It will return false if you are not on a taxonomy term archive page. function wpse52578_get_current_term_id(){ if( !is_tax() && !is_tag() && !is_category() … Read more

How do I taxonomy terms based on terms they are used alongside?

So my solution on this kind of problems where we have a very complex set of rules is to avoid doing new SQL just for my solution because if you have to explain it to a beginner it gets hairy. My solution: function get_term_union( $taxonomy, $tax_query, $post_type=”post” ){ $args = array( ‘post_type’ => $post_type, ‘tax_query’ … Read more

tax_query operator woes

I’m not sure that there is a way to get it to use ‘OR’ instead of ‘AND’. Alternatively, you can do: $myquery[‘tax_query’] = array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘regions’, ‘terms’ => array(‘region1’), ‘field’ => ‘slug’, ‘operator’ => ‘IN’ ), array( ‘taxonomy’ => ‘population’, ‘terms’ => array(‘pop1’), ‘field’ => ‘slug’, ‘operator’ => ‘IN’ ), … Read more

Creating a multi-taxonomy query, excluding the newest (read: highest ID) taxonomy term

Have you considered using a more standard loop, like this? I think it might fix your issue #3. $query = new WP_Query( $args ); echo ‘<div class=”home-middle widget-area”>’; echo ‘<h4 class=”widget-title widgettitle”><span>From the Archives</span></h4>’; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); echo ‘<article class=”post type-post status-publish format-standard has-post-thumbnail entry”>’; echo ‘<a href=”‘ . get_the_permalink() . … Read more

Formulate a url to show posts with both taxonomy terms

Looks like you can define the AND logical operator with the URL parameters, specifically adding the “+” between your terms like this: url?taxonomy=term1+term2 This will ensure that only posts containing all terms listed are returned. Example: https://example.com/blog?food=sauce+cheese [tax_query] => WP_Tax_Query Object ( [queries] => Array ( [0] => Array ( [taxonomy] => food [terms] => … Read more

Create Advanced search with taxonomies (not filter list)

like other times, after posting here i found my own question. Maybe its not the smarter solution but its working for me. Im using the new tax_query as commented in http://www.wpmods.com/query-multiple-taxonomies-in-wp-3-1/ Basically if i get 2 taxonomies with two terms for example $job_type=”full-time+free-lancer”; $job_cat=”designer+programmer”; I do the following: $custom_query=false; $myquery[‘tax_query’] = array( ‘relation’ => ‘AND’); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)