Exclude Specific Term from Search

The basic explanation You have a template tag that is called is_search() to determin if you’re on a search page or not. This then calls get_search_template() which basically is a wrapper function for get_query_template(‘search’). When you look into the last function, then you’ll see that it basically does locate_template(), which checks for file existence and … Read more

Determine Term depth

Not trying to bump my rep, but I found my own answer. get_ancestors allows you to get the hierarchy of any item. Since terms can only have 1 parent, this is all we need: the number of items in this list equates to the term depth level, and even provides term ids. Usage: $ancestors = … Read more

Can custom taxonomies be displayed inside of a custom meta box?

The following is taken from a “move author to publish box” task, but it should give you a starting point. Next you should take a look at “/wp-admin/edit-form-advanced.php” where you’ll find something about get_object_taxonomies() to see how your stuff get’s named, so you can remove and add stuff. function wpse_remove_author_box() { if ( ! is_admin() … Read more

Filtering custom taxonomies

This is not a tought quest, but you’d have to read carefully the Codex. Especially tax_query part of WP_Query. Your proposed query_posts call is wrong. This should look like this: query_posts( array( ‘post_type’ => ‘myportfoliotype’, ‘paged’ => $paged, ‘posts_per_page’ => 80, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, //or tag or custom taxonomy ‘field’ => … Read more

How to assign multiple roles for capabilities array withini register_taxonomy function?

When assigning capabilities to ‘capabilities’ argument of register_taxonomy() you need to assign the capability and not the role! so use capabilities that only a specific role has eg: ‘capabilities’ => array ( ‘manage_terms’ => ‘manage_options’, //by default only admin ‘edit_terms’ => ‘manage_options’, ‘delete_terms’ => ‘manage_options’, ‘assign_terms’ => ‘edit_posts’ // means administrator’, ‘editor’, ‘author’, ‘contributor’ )

Include and Exclude Taxonomies From Archives & Feeds Using ‘pre_get_posts’

I’ll take another shot. The following should modify the main query, such that it will include in its loop any posts that belong to no term of the Edition custom taxonomy. add_filter(‘pre_get_posts’,’better_editions_archive’); function better_editions_archive( $query ) { if ( $query->is_tax( ‘edition’ ) && $query->is_main_query() ) { $terms = get_terms( ‘edition’, array( ‘fields’ => ‘ids’ ) … Read more

How to display custom taxonomies in posts?

The easiest way to list terms of custom taxonomy and display them would be to use <?php get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?> For example in the loop, my custom taxonomy is ‘jobs’ list as li <ul><?php echo get_the_term_list( $post->ID, ‘jobs’, ‘<li class=”jobs_item”>’, ‘, ‘, ‘</li>’ ) ?></ul>