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

Are Custom Taxonomy Templates Possible?

Custom Taxonomy templates are entirely possible, the order of the template loading is, taxonomy-{sometax}-{someterm}.php – If the taxonomy were sometax, and taxonomy’s slug were someterm taxonomy-{sometax}.php – If the taxonomy were sometax. taxonomy.php archive.php index.php This template hierarchy give you tons of control on how you want to alter the display of taxonomies as a … 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

How to query custom post type by term?

You cannot make up your own arguments – rather than replacing the ‘category’ argument with your taxonomy name, use ‘tax_query’. See “taxonomy parameters” section of the codex on get_posts. $args = array( ‘post_type’ => ‘event’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘eventcategory’, ‘field’ => ‘slug’, ‘terms’ => ‘nice-events’, ), ), ); $your_query … Read more

Getting WordPress custom taxonomy/category?

I think you are getting confused by terminology here. Category is a taxonomy. Specific categories you create are terms. our_gallery is taxonomy. Landscapes is term. our_gallery is not category. It is its own taxonomy and has nothing to do with category taxonomy. get_the_category() function explicitly fetches terms of category taxonomy. To get terms of our_gallery … Read more

How i add new link after Edit | Quick Edit | Trash | View in quick edit section

You can do it by creating a hook for post_row_actions filter. If your CPT is hierarchical post type use page_row_actions filter. add_filter( ‘post_row_actions’, ‘wpse8170_row_actions’, 10, 2 ); function wpse8170_row_actions( $actions, WP_Post $post ) { if ( $post->post_type != ‘my-custom-post-type’ ) { return $actions; } $actions[‘wpse8170-pdf’] = ‘<a href=”http://your/url/here”>PDF</a>’; return $actions; }

Get only parent terms from wp_get_post_terms

wp_get_post_terms doesn’t accept ‘parent’ or ‘hide_empty’ parameters in it’s arguments array, only ‘orderby’,’order’ and ‘fields’ but you are on the right track, simply add a conditional check before you echo out the slug: function project_get_item_classes($post_id = null) { if ($post_id === null) return; $_terms = wp_get_post_terms($post_id, ‘construction_type’); foreach ($_terms as $_term) { if ($_term->parent == … Read more