Why does a custom post type need the ”hierarchical’ args setting?

When you have two content objects with a similar interface or shared properties, you have a good candidate for hierarchical post types. Take places as an example (see this answer): Asia Europe Germany Berlin Austria Vienna Each place has similar meta data: population, geo coordinates, spoken languages. You just can reuse the same interface. Plus, … Read more

Custom Taxonomy in plugin and template

First of all – plugins are for generating content, themes are for displaying it. So really, a plugin shouldn’t do this. But there are grey areas – for example in an ‘events’ related plugin, it would be desirable to display dates, venue etc – things that a WordPress theme wouldn’t normally display. I would suggest … Read more

Is there a (relatively easy!) way to create relationships between taxonomies WITHOUT needing a post as an intermediary

Using standard WordPress functionalities this is, simply, not possible, unless using complicated and poorly performing tricks. The method I suggest you is to create your custom table where store relationship. It should consists of 5 columns: person_id | post_id | post_type | taxonomy | term_id Now, copying out your example: Person A may be the … Read more

Custom Taxonomy with Custom Post Type Finds No Posts

I don’t know how or why, but this code below solved by issue. Seems to me like I shouldn’t need it, but apparently I do. add_filter(‘pre_get_posts’, array(&$this, ‘modify_pre_query_request’)); public function modify_pre_query_request($query){ if ($query->is_main_query()){ if ($query->is_tax){ $post_type = get_query_var(‘post_type’); if (!$post_type){ $post_type = array( ‘post’, ‘YOUR POST TYPE’ ); $query->set(‘post_type’, $post_type); } } } } Keep … Read more

Exclude specific slug in ‘get_terms’

The get_terms() (see docs) function accepts the same args as WP_Term_Query(see docs) You have to get those terms Ids first and then pass it to the exclude arg: // default to not exclude terms $ids_to_exclude = array(); $get_terms_to_exclude = get_terms( array( ‘fields’ => ‘ids’, ‘slug’ => array( ‘graduate’, ‘job-market-candidate’, ‘graduate-student’, ‘research’ ), ‘taxonomy’ => ‘role’, … Read more