Get used terms by an author as array of strings

I don’t know which line that error refers to but this code works correctly if everything falls into place exactly right. But there are actually several ways this could go wrong. For example, if get_query_var(‘author_name’) is not set you get an error on this line: $used_terms=list_author_used_terms($user->ID); If a problem occurs here: $terms = wp_get_object_terms( $p->ID, … Read more

Include custom post type in “all posts”

Filter pre_get_posts: add_filter( ‘pre_get_posts’, ‘wpse_98213_add_post_types_to_tax_query’ ); /** * Let WP search for custom post types on taxonomy archives. * * @wp-hook pre_get_posts * @param object $query * @return object */ function wpse_98213_add_post_types_to_tax_query( $query ) { if ( ! is_main_query() or ! is_tax( ‘your_taxonomy_name’ ) ) return $query; $query->set( ‘post_type’, array ( ‘portfolio’, ‘post’ ) ); … Read more

Exclude Custom Taxonomies

Your tax_query is incorrect. taxonomy does not take an array. taxonomy (string) – Taxonomy. http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters You will need to rewrite your arguments to be more like the following from the Codex: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ … Read more

Dynamically tax_query

Just needs a little array manipulation. $def = array( ‘taxonomy’ => ‘cities’, ‘field’ => ‘slug’, ‘operator’ => ‘NOT IN’ ); $cities = array( ‘boston’, ‘chicago’ ); $args = array(‘relation’ => ‘OR’); foreach ($cities as $c) { $args[] = wp_parse_args(array(‘terms’=>$c),$def); } print_r($args); The $cities array you need to build from your $_POST or $_GET form data, … Read more

Custom taxonomy archive page not working

Your permalink as given is domain.com/curriculum-area/equality but you registered your taxonomy as Curriculum Area. For domain.com/curriculum-area/equality to work, change Curriculum Area in: register_taxonomy( ‘Curriculum Area’, ‘course’, $args_curriculum_area_taxonomy ); to be: register_taxonomy( ‘curriculum-area’, ‘course’, $args_curriculum_area_taxonomy ); Also change this line ‘taxonomies’ => array( ‘curriculum_area’ ), to ‘taxonomies’ => array( ‘curriculum-area’ ), I forgot to say, remember … Read more

List all posts in Custom Post Type but group dynamically by Custom Taxonomies

Try this piece of code for page template. I’ve used it on one of my projects. It outputs taxonomy term one by one with list of all posts with this term. (Just replace YOUR_TAXONOMY_SLUG to yours) <div id=”content”> <h2 class=”entry-title”><?php the_title(); ?></h2> <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> $mytaxonomy = get_terms(‘YOUR_TAXONOMY_SLUG’, array(“fields” => “names”)); … Read more