Add Category Name to REST API

The API responses are designed to only return the IDs. You can then fetch the full information for each term. Of course it would not be very performant to make dozens of requests. So instead, the REST API has the concept of embedding resources. If you make your request, but include _embed=1 in your URL, … Read more

Using a different template per Custom Taxonomies for single term archive pages

I would intercept the template loader at template_redirect: function wpse53892_taxonomy_template_redirect() { // code goes here } add_action( ‘template_redirect’, ‘wpse53892_taxonomy_template_redirect’ ); Then, you would check to see if the query is a custom taxonomy: if ( is_tax() ) { // This query is a custom taxonomy } Next, get the term object, and find out if … Read more

Using a loop to display terms associated with a post

This answer was a joint effort with tnorthcutt so I made it community wiki. There are several interesting functions available: the_taxonomies(), which calls get_the_taxonomies(), which in turn calls get_object_taxonomies() and wp_get_object_terms(). the_taxonomies() is a documented template tag and is a light wrapper around a call to get_the_taxonomies(), which is undocumented. get_object_taxonomies() returns a list of … Read more

If taxonomy exists then to show some code

If you want to check for the existence of a taxonomy, use taxonomy_exists( $taxonomy ): <?php if(taxonomy_exists(‘country’)){ echo ‘All courses in’ . get_the_term_list($post->ID,’country’, ‘ ‘, ‘ ‘, ” ); } ?> etc… Edit If, instead of checking for the existence of a taxonomy, you want to check if the current post belongs to a taxonomy, … Read more

Can I turn off write-in tags/taxonomies?

Here is what I came up with, seems to work: add_filter( ‘pre_post_tags_input’, ‘no_tags_input_create’ ); add_filter( ‘pre_post_tax_input’, ‘no_tax_input_create’ ); function no_tags_input_create($tags_input) { $output = array(); foreach( $tags_input as $tag ) if( term_exists( $tag, ‘post_tag’) ) $output[] = $tag; return $output; } function no_tax_input_create($tax_input) { if( !isset($tax_input[‘post_tag’]) ) return $tax_input; $output = array(); $tags = explode(‘,’, $tax_input[‘post_tag’]); … Read more

Ajax post filter by taxonomy

I believe WordPress can handle multiple query parameter by default. You can load http://wordpresssite.com/?taxonomy-1=term-a&?taxonomy-2=term-b to query all post that belongs to term a (in taxonomy 1) AND term b (in taxonomy 2). Use JQuery load() function to load the intended query parameter, based on the selected item on the sidebar. Hope this help.

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