wp_get_object_terms – How can I order the resulting array by hierarchy?

Just a rough sketch to get your idea: countries (hierarchical taxonomy) France (country – sub taxonomy) Champagne (state – sub sub taxonomy) Le Mans (city – term) Angers (city – term) Nantes (city – term) And you want to order: $query_results = query( ‘country’ => ‘france’, ‘orderby’ => ‘state city’, ‘order’ => ‘ASC’ ); Did … Read more

Sort posts by number of matched terms

Well the only way i can think of is to create an two dimentions array of the results you want to output, and the number of matching tags. so for example: $results = array(); $searched_tags = $_post[‘my_tax’]; $searched_tags = explode(“+”, $searched_tags); while (have_posts()){ $the_post(); $result[‘r’] = ‘<div class=”post”> <div class=”title”><h2><a href=”‘.get_permalink($post->ID).'” title=”‘.get_the_title($post->ID).'”>’.get_the_title($post->ID).'</a></h2></div> <div class=”excerpt”>’.get_the_excerpt().'</div> </div>’; … Read more

Dynamically Create Terms in Taxonomy when Custom Post Type is Published. Almost There!

You’re almost there – the problem is you’re trying to access the $post object when the function only receives the post ID. add_action( ‘publish_country’, ‘add_country_term’ ); function add_country_term( $post_ID ) { $post = get_post( $post_ID ); // get post object wp_insert_term( $post->post_title, ‘country_taxo’ ); }

The same slug in multiple taxonomies

When you say keyword, do you mean term? I just did a quick test to confirm: I can have the same term, which has the same slug, in both the Category and Post Tag taxonomies, so I assume that custom taxonomies likewise can have terms with the same slug. So, might there be some taxonomy/term … Read more

WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?

I had the same question a couple of weeks ago. Here’s what I did to make it work for me. How Do I Use WP_Query to Run This Database Query as Search Result? If you’ll read through my answer that I posted for reference’s sake, you’ll see that I ended up adding a filter add_filter(‘post_request’,’your_function_name’); … Read more