How could I write a get_categories_by_year() function?

I would do this with SQL query. Doing it in PHP will be a little bit slow, I guess. This function should do the job: function get_categories_from_year($year) { $sql = “select term.* from {$wpdb->terms} term inner join {$wpdb->term_taxonomy} tax on (term.term_id = tax.term_id) inner join {$wpdb->term_relationships} relation on (tax.term_taxonomy_id = relation.term_taxonomy_id) inner join {$wpdb->posts} post … Read more

Taxonomy Overview Page?

If all you’re trying to do is to display all post types on the taxonomy archive, then you can easily accomplish that by filtering the query at pre_get_posts. Assuming a taxonomy foobar: function wpse111033_filter_pre_get_posts( $query ) { if ( $query->is_main_query() && $query->is_tax( ‘foobar’ ) ) { $query->set( ‘post_type’, ‘any’ ); } } add_action( ‘pre_get_posts’, ‘wpse111033_filter_pre_get_posts’ … Read more

Copy post taxonomy?

Yes, you don’t need a custom taxonomy, but a custom post type for courses, and probably a custom taxonomy for courses categories. In WordPress post types are containers for a certain type of information: every information type is a post type. E.g. Posts are a type and Pages are another type. Every post type (container) … Read more

Query custom taxonomy for category including children

tax_query is used to get the posts associated with certain taxonomy. {tax} (string) – use taxonomy slug. Deprecated as of Version 3.1 in favor of ‘tax_query’. tax_query (array) – use taxonomy parameters (available with Version 3.1). taxonomy (string) – Taxonomy. field (string) – Select taxonomy term by (‘id’ or ‘slug’) terms (int/string/array) – Taxonomy term(s). … Read more

Custom Post Type Taxonomy Term Order by Title

After about 100 different tries, I got it to work. Not sure if there is a better way, but it works. $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); $current_term = get_term_by( ‘slug’, $term_slug, $taxonomyName ); $args = array( ‘post_type’ => ‘clients’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’=>array( array( … Read more

Don’t display taxonomy if empty

What you need is set the show_option_none to a string easily recognizable and then add the result of wp_list_categories to the content only if it it does not contain that string.. So your foreach loop shoul look somethinlg like foreach( $taxonomies as $taxonomy ) { $args = array( ‘orderby’ => ‘name’, ‘echo’ => false, ‘taxonomy’ … Read more

Problems making shortcode with custom post types and taxonomy

That is a very broken Loop. The results of a new WP_Query is not a simple array that you can foreach over. It is far more complicated than that. Try var_dump($work_galleries);. Fortunately, WP_Query provides methods to make looping easy. $work_galleries = new WP_Query($args); if ($work_galleries->have_posts()) { while ($work_galleries->have_posts()) { // this replaces foreach $work_galleries->the_post(); // … Read more