Show all terms of a custom taxonomy?

You need to pass an additional argument to get_terms(). The default is to hide “empty” terms– terms which are assigned to no posts. $terms = get_terms([ ‘taxonomy’ => $taxonomy, ‘hide_empty’ => false, ]); EDIT: Incase you want to display the name or the slug of the enlisted custom taxonomies being held by the $terms variable … Read more

Include custom taxonomy term in search

I would recommend the Search Everything plugin too, but if you want to implement this using WP’s search function, here’s the code I’m using in my Atom theme: // search all taxonomies, based on: http://projects.jesseheap.com/all-projects/wordpress-plugin-tag-search-in-wordpress-23 function atom_search_where($where){ global $wpdb; if (is_search()) $where .= “OR (t.name LIKE ‘%”.get_search_query().”%’ AND {$wpdb->posts}.post_status=”publish”)”; return $where; } function atom_search_join($join){ global … Read more

Add category base to url in custom post type/taxonomy

Change your rewrite to add the course query var: ‘rewrite’ => array(‘slug’ => ‘courses/%course%’) Then filter post_type_link to insert the selected course into the permalink: function wpa_course_post_link( $post_link, $id = 0 ){ $post = get_post($id); if ( is_object( $post ) ){ $terms = wp_get_object_terms( $post->ID, ‘course’ ); if( $terms ){ return str_replace( ‘%course%’ , $terms[0]->slug … Read more

Get Posts Under Custom Taxonomy

Your tax query is incorrect, field should be the field you want to query on: term_id, name, or slug – $posts_array = get_posts( array( ‘posts_per_page’ => -1, ‘post_type’ => ‘fabric_building’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘fabric_building_types’, ‘field’ => ‘term_id’, ‘terms’ => $cat->term_id, ) ) ) );

How to Add Tags to Custom Post Type?

Like this: (Where it says “portfolio” is where you register the taxonomy to a post type add_action( ‘init’, ‘create_tag_taxonomies’, 0 ); //create two taxonomies, genres and tags for the post type “tag” function create_tag_taxonomies() { // Add new taxonomy, NOT hierarchical (like tags) $labels = array( ‘name’ => _x( ‘Tags’, ‘taxonomy general name’ ), ‘singular_name’ … Read more

How do I query a custom post type with a custom taxonomy?

Firs of all don’t use query_posts() ever, read more about it here: When should you use WP_Query vs query_posts() vs get_posts()?. You have to use WP_Query to fetch posts what you need. Read documentation for it. In your case the query could be like this: $the_query = new WP_Query( array( ‘post_type’ => ‘Adverts’, ‘tax_query’ => … Read more

Permalinks: custom post type -> custom taxonomy -> post

First, register your taxonomy and set the slug argument of rewrite to shows: register_taxonomy( ‘show_category’, ‘show’, array( ‘rewrite’ => array( ‘slug’ => ‘shows’, ‘with_front’ => false ), // your other args… ) ); Next, register your post type and set the slug to shows/%show_category%, and set has_archive argument to shows: register_post_type( ‘show’, array( ‘rewrite’ => … Read more