WordPress 3.0 custom post types, taxonomies & Thesis

With the recent launch of WordPress 3.0 there are loads of sweet new features to dig into. Digging into WordPress has a nice summary of many of the new features.

My favourite new features include the custom post types and custom taxonomies (which have been available for a while, but the dashboard management capability has been fully implemented now). I guess those are slightly more advanced features, I think most users may be more excited by backgrounds, header and menus. As such, Matt Hodder already has a great post about enabling WP 3.0 menus, backgrounds and headers in Thesis.

Also, there is an issue with the Thesis Custom File Editor in the dashboard, so if you use that a lot definitely check out the fix for the use_codepress() error.

Today I’m going to cover my favourite new WP 3.0 features.

Custom Taxonomies

Taxonomies are ways to classify posts and custom post types. WordPress has had two taxonomies for a long time: categories and tags. You’ve been able to register custom taxonomies in WordPress for quite a long time and since version 2.7 registering a non-hierarchical taxonomy (similar to tags) has provided a new input box in the post editing screen to assign your custom tag type to posts, but there was no menu item to edit that taxonomy and there was no input support for hierarchical taxonomies (like categories).

Now, registering a new taxonomy provides the input box on post editing pages and a dashboard menu item to edit the whole taxonomy.

Say you were building a website to document the spread of an infectious zombie-creating disease and wanted to profile and categorise individual zombies… You could create a custom post type for zombies (covered below) and assign location and infection taxonomies to make it easy to categorise and query where the zombies were sighted, or originated from, and which strain of the infection they have.

The following code would be posted into functions.php, or custom_functions.php for Thesis.

function my_custom_taxonomies() {
		'location',		// internal name = machine-readable taxonomy name
		'zombie',		// object type = post, page, link, or custom post-type
			'hierarchical' => true,
			'label' => 'Location',	// the human-readable taxonomy name
			'query_var' => true,	// enable taxonomy-specific querying
			'rewrite' => array( 'slug' => 'location' ),	// pretty permalinks for your taxonomy?
			'hierarchical' => false,
			'label' => 'Infection',
			'query_var' => true,
			'rewrite' => array( 'slug' => 'infection' ),

add_action('init', 'my_custom_taxonomies', 0);

The lines in the first registration are commented to explain them a bit, and another post by Justin Tadlock has some more details about custom taxonomies.

Notice that I made the Location taxonomy hierarchical, since I figured I could hone down the location as much as I want, and organise it in a hierarchy of country, state, city, suburb, etc. Also I only enabled it on “zombie” objects, that is, my Zombie post type. However, for the Infections tag I enabled it on posts because I figured I may write posts about the different strains and their evolution. I can enable the Infections taxonomy on Zombie post types within the post type registration below.

Custom Post Types

Custom post types are new in WP 3.0. They are like posts and pages, but are handled separately within the WordPress dashboard and by the regular post query — like pages, they don’t show up on the posts page or in the feed.

When creating custom post types you can call them whatever name you like and you can mix some of the features of posts and pages. For example, you can create a custom post type that is hierarchical (like pages, allowing child pages) and that uses categories, tags or custom taxonomies (like posts already do).

Justin Tadlock has an amazing post with the details of custom post types and how to make them. Refer to that post for all the parameters related to creating custom post types.

In Thesis, creating custom post types is not very different to any other theme. The main difference is that instead of adding the registration code to functions.php you add it to custom_functions.php.

// === CUSTOM POST TYPES === //
function create_my_post_types() {
	register_post_type( 'zombie',
			'labels' => array(
				'name' => __( 'Zombies' ),
				'singular_name' => __( 'Zombie' ),
				'add_new_item' => 'Add New Zombie',
				'edit_item' => 'Edit Zombie',
				'new_item' => 'New Zombie',
				'search_items' => 'Search Zombies',
				'not_found' => 'No zombies found',
				'not_found_in_trash' => 'No zombies found in trash',
			'_builtin' => false,
			'public' => true,
			'hierarchical' => false,
			'taxonomies' => array( 'location', 'infection'),
			'supports' => array(
			'rewrite' => array( 'slug' => 'zombie', 'with_front' => false )
add_action( 'init', 'create_my_post_types' );

There are loads more parameters that you could use. I found that these were the ones I needed to create a pretty simple post type with a smooth experience (i.e., all the terms in the admin call the posts “zombie” or “zombies” appropriately, rather than “posts” or “pages”).

Worth noting is that even though the default slug (bit of the URL) will be the label (in this case “zombie”), I had to specifically state it in the registration code, otherwise I got a 404 error on my post. Also, you need to visit the permalink settings page after registering the post type to flush the rewrite rules so the new slugs work (just visit the page, you don’t have to re-save the options).

Thesis SEO & image metadata for custom post types

You might have noticed that the last line of my custom post type registration, //'register_meta_box_cb'=>'add_meta_boxes',, is commented out. Don’t uncomment it because it won’t work! To add meta boxes to the custom post type editing page, you need to provide a callback function and state the function name in the registration code. Thesis doesn’t support this yet, which is why I have custom fields enabled on the editing page. You can still use the Thesis SEO and image fields, but it will be a bit more manual until the callback is supported. I’ve left the line in the code to remind myself to add the callback in when it’s ready and I’ll edit this post to include it when it is.

If you’ve been using the Thesis fields then the keys will probably be available for you in a select box when adding a new custom field. Some of the values you will know what to do with, such as thesis_post_image and thesis_thumb just take an image URL, but if you’re not sure what values to use take a look at the custom fields on one of your older posts already using the Thesis meta to see what should be entered as the value for the field.

To add the Thesis meta boxes to your custom post editing page add the following to custom functions. Courtesy farinspace.com.

function custom_thesis_meta_boxes() {
	$post_options = new thesis_post_options;
	foreach ($post_options->meta_boxes as $meta_name => $meta_box) {
		add_meta_box($meta_box['id'], $meta_box['title'], array('thesis_post_options', 'output_' . $meta_name . '_box'), 'zombie', 'normal', 'high');
	add_action('save_post', array('thesis_post_options', 'save_meta'));

Be sure to change the “zombie” in bold to the name of your custom post type. To add to more than one custom post type, try the following function, adding your custom post types to the array $post_types.

function custom_thesis_meta_boxes() {
	$post_options = new thesis_post_options;
	$post_types = array('zombie','other_post_type');
	foreach ($post_types as $post_type) {
		foreach ($post_options->meta_boxes as $meta_name => $meta_box) {
			add_meta_box($meta_box['id'], $meta_box['title'], array('thesis_post_options', 'output_' . $meta_name . '_box'), $post_type, 'normal', 'high');
		add_action('save_post', array('thesis_post_options', 'save_meta'));

More to come

There’s a lot more to WordPress 3.0, but I think this post is long enough. I’m sure I and others will have more exciting things to come!


  1. says

    Awesome post and thanks for the mention! I’ve been playing around with custom post types and just loving the possibilities.

  2. says

    Really Nice Post!
    Lots More Features In WP 3… :) Thanks To WordPress Team Also …

    Thanks Kristarella For Telling How To Add These Features Into Thesis!
    Also Matt Has Written A Great Article… Will Help Me A Lot!

  3. says

    May not be everyone’s experience, but if you define custom posts with pretty permalinks, you may need to re-save the permalinks settings panel in WordPress before WordPress will recognize the new slugs. I was getting 404s on my custom post type entries until I did so.

    Great article, Kris. Anyone interested in all the possible options and so on, check out the WP Codex. 😀

  4. says

    Matt — Thanks, and no prob! I’m all for promoting wach other’s posts rather than rewriting the same tutorial a million times!

    Saif — Thanks, hope you have some fun with these customisation possibilities.

    Rick — Cheers! Thanks for the link to the codex. I was looking at a page on the codex, but it was not useful enough to link to, I think it was a general description page rather than the function reference.

  5. says

    Wow great blog! I also use thesis and am very impressed with your styling, you make me feel like a newbie.

    I like the wordpress 3.0 layout its much more crisper than their last version. I like the fact that they make adding headers easier. Also after reading this post I need to dig into thesis more I think I am missing out on a lot of cool features because of my own ignorance. DOH!

  6. says

    Larry — Thanks :-)

    Yes, I quite like the interface changes for WP3 as well. Don’t worry too much about missing features. It’s good to dig deep and get creative with the tools you have, but it’s still a learning process. Everyone has to start at knowing little at first, then knowledge can grow… it’s half the fun!

  7. says

    I have a couple custom taxonomies and I want to use them in the sidebar as I would categories. I want to be able to show a list (preferably in a drop down) and when the user selects a term, WordPress shows those posts that have that term assigned to them. Just like a category widget does.

    Does this widget exist? Is there code I can out in a widget that would do this?

  8. says

    You mentioned that //’register_meta_box_cb’=>’add_meta_boxes’, does not work with Thesis. I needed custom meta boxes for a web app I am writing. This tutorial works shows how to get custom meta boxes working on your site… and this method jives with Thesis too!


    In fact, the edit page for one of our custom post types is now 100% meta boxes since we don’t need the WYSIWYG for this post type.


  9. says

    Mark — I couldn’t find any new functions to automatically create lists or dropdowns for the new taxonomies, but the following function pasted into custom_functions.php will do it (it sticks with the “locations” example, you’ll need to substitute your own values in there.

    function location_dropdown() {
    <li class="widget">
    <h3>Browse by Location</h3>
    	<select name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> 
    		<option value=""><?php echo attribute_escape(__('Select Location')); ?></option>
    	$locations = get_terms('location','hide_empty=0&hierarchical=0');
    	foreach ($locations as $location) {
    		$option = '<option value="' . get_bloginfo('url') . '/location/' . $location->slug . '">';
    		$option .= $location->name;
    		$option .= ' (' . $location->count . ')';
    		$option .= '</option>';
    		echo $option;

    See the codex page for get_terms() if you need more parameters in that function.

  10. says

    Nick — Thanks! I’m sure that link will come in handy. When I said the register line didn’t work I was talking specifically about the Thesis SEO & image meta boxes: the ones provided by Thesis. I didn’t mean any meta box that you care to create. Did you find a callback to add the Thesis meta boxes, or was that part of the post just not clear enough?

  11. says

    Oh, I get it now. Upon re-reading your post I see now that you are Specifically referring to Thesis MetaBoxes. Sorry about that!

    No, I have not found any way to get Thesis Meta Boxes to load on Custom Post Types. Yet.


  12. says

    Hey Kristarella,
    I’ve got a simple question for you that has absolutely nothing to do with the topic of this post… which was wonderful by the way, but instead with the features of this post.

    You have a fantastic little “Contents” menu in the upper right hand side of this post. I love it and I’ve been searching for a plugin or some other method of accomplishing this with some of my longer posts… but I haven’t found anything. Would you care to share how you made that little “Contents” menu?
    Thanks a ton.

  13. says


    Here’s something I’m struggling with. I have set up a couple custom taxonomies. But I’d like to set up the META Description for each taxonomy archive page. I want to insert the taxonomy term description into the META Description. How do I add the META description for a taxonomy page? I understand the if_tax conditional statement, but what else do I have to do?

    I’ve been able to figure out how to create an H1 title and show the term description on-page, and all I need is the to get this META description working to be able to use the taxonomies.

    Also, the custom taxonomy archive pages do not have nofollow. This sounds dangerous for duplicate content. I’d like to initially set all taxonomies to no follow while I get set up,, but then would would be a great piece of code would be allow follow IF there is something in the taxonomy term description for that term!

    (I wonder if Chris is going to add the meta, nofollow, etc fields to 1.8?)

  14. says

    Richard — The contents menu is implemented via javascript (jQuery) and only requires the subheadings in the post to have IDs in order to link to them. I think I’ll write a post about it, rather than just dumping the code in here. Watch out for that later today.

    Mark — As far as I can tell there is no description output on a custom taxonomy page by default in Thesis, so you would just add one via custom_functions.php.

    function custom_SEO() {
    	if (is_tax()) :
    		$description = strip_tags(term_description('', get_query_var( 'taxonomy' )));
    		echo '<meta name="description" content="' . $description . '">';

    It appears that by the default Thesis settings the custom taxonomy pages do have noindex,nofollow. I have the <meta name="robots" content="noindex,nofollow"> tag on my taxonomy test page, and I haven’t changed any of the Thesis settings. I guess if it’s not there with your settings, then you can add it within the function above.

  15. says

    I don’t think people realize yet what a powerful feature the custom posts and taxonomies are. This improvement has brought WP to level par feature-wise with other cmss which cater to general (non-blog) sites.

    Thanks for the runup of how to implement it.

  16. says

    Thanks once again, Kristarella, for the custom_SEO function. Works great!

    Interesting how you have a noindex on your taxonomy pages. I have this
    tag. I wonder why the difference? Interesting. But I’ve created a robots.txt file to disallow indexing of my custom taxonomies.

    I hope that the next release of Thesis will have all the Page Options fine tuning for custom taxonomies as it has for tags and categories. I’ve asked on the Thesis forum, but trying to get any information about bug fixes (Thesis is horrible with bug fixes), upcoming features, and estimated, even extremely rough, timing of new releases is worse than pulling teeth.

  17. Chris says

    I have a custom post type and some categories within that post type. I then have a page that displays each custom post type by category. When I click to view the single page view of the custom post I get a 404. So the URL should be /customposttype/category/postname, but they links aren’t going there when i click on them, they are going to /customposttype/postname. How do I change this? Also the url that should work, doesn’t. When I put default permalinks on everything is fine.

  18. says

    Chris — Please provide the code you’re using to register the post type and create the page listing post types. If it’s quite long try using Pastebin.com and sending the link. I don’t think I can help without seeing the code.

  19. says

    Chris — Much of this is all a bit new to everyone, so bear with me. Some issues I see so far is that you said the URL should be “/customposttype/category/postname”, but why? As far as I’ve seen, custom post types URLs are pretty much just “/custom-post-type/custom-post-name”, I haven’t found a way to add the category into the URL. Also, you haven’t enabled categories in your Portfolio post type, so you must mean the URL should contain the genre taxonomy? Unless giving the Portfolio post type “post” capabilities gives it the same taxonomies as posts too, I haven’t explored that option.

    The other thing that might be messing up URLs is that you’ve given the genre taxonomy a slug of “portfolio”, but custom post types are given a default query and slug of their label, and “portfolio” is the label of your custom post type. So you should probably change the slug of the genres taxonomy, or specify a slug for portfolio post types. And as I mentioned in the post, I found that if I didn’t specify a slug for custom post types, even though the default slug is supposed to be the label, I got a 404 for the posts.

    If you fix up the slugs you should not get 404s anymore, but I don’t know yet if there’s any way to use a taxonomy in the custom post URLs. I wan’t able to figure it out last week and haven’t tried again yet. I’m hoping that if it’s possible Justin Tadlock will write about it soon because he’s been promising more posts on this topic.

  20. Chris says

    Yes, its a taxonomy, sorry. I will try changing the slugs up. As far as the URL, it doesn’t really matter, I was confused. I just want to not get 404s with pretty permalinks, however the URL needs to show up. Thanks for the help, I will let you know how it goes when I try it.

  21. Chris says

    Alright, fixed it. It was the slug problem, and I had a stray “<" in my category.php that I just didnt see, lol. I'm embarrassed now. DOH!

  22. says


    I am using the custom post types plugin for now. I have just uploaded a post but it does not appear either under posts or pages which I guess it shouldn’t. But how do I make it appear in the nav menu. I use thesis theme.

  23. says

    Thanks for a great round up Kristarella. I found this on the thesis forums to allow you to add the thesis meta data to custom post types, though I doubt it will be needed when 1.8 final is here. Anyway here it is

    add_action(‘admin_init’, ‘thesis_for_custom_post_types’);function thesis_for_custom_post_types() { $post_options = new thesis_post_options; $post_options->meta_boxes(); foreach ($post_options->meta_boxes as $meta_name => $meta_box) { add_meta_box($meta_box[‘id’], $meta_box[‘title’], array(‘thesis_post_options’, ‘output_’ . $meta_name . ‘_box’), ‘custom_type_name’, ‘normal’, ‘high’); #wp } add_action(‘save_post’, array(‘thesis_post_options’, ‘save_meta’));}

  24. says

    Marvin — Try using the link category method of adding links to the nav menu (add the link as a blogroll type link to a link category and add that category to the Thesis nav).

    David — Thanks for that! Great to know.

  25. says

    No problem I often admire your work from afar. I am enjoying working with these new capabilities and eager to see if 1.8 final includes the same tag and cat support for the taxonomies both in terms of the seo options in the dashboard and the pages they produce. Havent quite nailed the custom templates for custom post types, im as far as tricking the code into thinking its a page type not a post type so its actually possible with thesis but yet to put together a near vanilla template to begin testing with.

    One other challenge, im trying to find the supports sub line for adding scribe support for the custom post type edit screen as its available on the standard post and page screens, any thoughts? Keep up the great work.

  26. says

    David — Sorry, I don’t know what would be in Scribe to hook it in to a custom post editor. They might not have built in direct support for 3.0 yet, but if you search the plugin files for add_meta you might find it.

    I haven’t really tried to add a single WYSIWYG: I don’t like them very much and prefer the code editor 😉

  27. says

    Hi Kristarella, I have inspected the plugins code and indeed found the meta and where it says add support for page and post, I created the additional call to support it for the new post type however think I still need to call it from the supports line in the add custom post type.

    I shall wait to see what scribe support say, they were quick to respond at first but then havent responded for a few days. I am sure its an issue many are hoping to have addressed.

    RE: wysiwyg I am looking into verve meta boxes as I believe one of their options supports adding a meta box with the wp additional controls. Il let you know if I have any luck as it could be a useful feature. It could potentially still be written in without the plugin after seeing how they address this.


  28. Daniel says

    “Also, you need to visit the permalink settings page after registering the post type to flush the rewrite rules so the new slugs work!”

    Good hint! My custom taxonomy slug wasn’t working until I re-visted the permalink page.


  29. says

    Isn’t defining new post type in the theme code just wrong? I’d imagine a plugin providing new post types rather than a theme.

  30. says

    Vincenzo — I wouldn’t say “it’s just wrong”. It makes sense to create your own plugin for it so that you don’t have to worry about it if you change your theme. But it is fairly common practice to pop this stuff in the functions file of your theme, and if you do you’d need to remember to copy over the code if you change themes, but the same goes for plenty of other customisations you might have.

  31. says

    Hi kristarella,
    nice article but i have a problem
    I added two taxonomies with the help of “GD CPT tools plugin”
    the 2 taxonomies are courses and location

    i want this to come in my permalink
    but it is not coming,
    i used this link
    but it is just showing %courses% and %location%

    and i already added taxonomies so if i want to write this code where should i write in which file?

  32. says

    I added two taxonomies with the help of “GD CPT tools plugin”
    the 2 taxonomies are courses and location

    i want this to come in my permalink
    but it is not coming instead its just coming %courses%/%location%
    whats the fault
    i already added taxonomies so if i want to write this code where should i write in which file?

  33. says

    Niraj — please just send me one message next time, not 2 comments and an email. I’m usually very prompt at responding to blog comments (I was asleep the whole time you sent your three messages).

    To repeat for anyone who might come looking for the same question: I don’t think WordPress has support for custom taxonomies in permalinks yet, but just to be sure, the place to check is in the WordPress forums.

  34. says

    sorry for two comments,
    so it is not possible to add more than one taxonomy in permalinks cause i am already using one category, and i wished to add more two i.e locations and courses
    is there any other method to add more taxonomies to permalink?
    cause i heard that there is also a way to add into permalinks through rewriting the wordpress rules again but that person is not sure about this,
    will this actually work?

  35. Sander Berg says

    Hi, thanks for your post. I was looking for a solution for something I need. I thought the answer would be taxonomies but after reading your post I think it’s not what I need. Maybe you can help me?
    Let’s say I have 2 custom post types: actors and interviews. In these post type I have custom fields, so for example actors has 3 extra custom fields and interview has 2 other custom fields.
    So now I enter some actors. Now I am going to enter an interview and see the fields + custom fields I need to enter. Now I also want some kind of field (checkboxes or dropdown) with the actors I entered as custom post type. This way I can link this interview with 1 or more of the actors that already exist. Is this possible with taxonomies? Or do I need something else?

  36. says

    Niraj — If my first instinct — that custom taxonomies are not able to be inserted into the primary permalink settings — is correct, then the answer is no, you can’t use categories and a custom taxonomy since you can’t use a custom taxonomy in your permalinks at all. I’ve looked through wp-includes/rewrite.php and there is no infrastructure for rewriting a custom taxonomy into the permalinks…
    My initial instinct was partially correct: it can’t be done with just plain WordPress, but you can write some custom filters to rewrite the URLs properly. See this post, custom permalinks for custom post types in WordPress 3.0. It’s for custom post types, not all posts. So far I haven’t been able to get it to work for plain posts, but I haven’t got more time to look at it today, so I though I’d just give you that link and you can take a look.

  37. says

    Sander — It sounds like you don’t necessarily want the actors as custom post types, but as a custom taxonomy to use with the interview post type. Or, you could have an actor taxonomy as well as an actor post type, assign actors to interviews as a taxonomy and then link the actor taxonomy page to the actor post.

  38. Sander Berg says

    Thanks for the reply. Yes, I indeed want actor as a custom type because there will be many custom fields for that type.
    If I use your solution, how do I link the actor custom post type to the actor taxonomy? By having the taxonomy select box both on the actor post type admin page and the interview post type page?

  39. says

    It gets a bit complicated because I don’t think you want to use the same name and slug for taxonomies as post types; i.e., probably better not to have a post type and taxonomy both with the name “actor” it could just get messy.

    Maybe if your post types are “actor” and “interviews” the taxonomy could be “interviewees” and then the URL for all the posts for a certain actor (that is the interview posts with the interviewee taxonomy assigned) would be /interviewees/firstname-lastname/ Then you can add a link at the top of that page to the actor post:

    function actor_link($content) {
    	if (is_tax()) {
    		$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    		echo $content;
    		echo '<p>See profile for <a href="/actor/' . $term->slug . '">' . $term->name . '</a>';
    		echo $content;

    I’m not 100% sure if that’ll work because it assumes that the taxonomy actor name slug is the same as the post actor name slug, and I’m not sure that’ll be the case. That is along the lines of how I’d go about it anyway, and likewise for linking to the interviews from the actor post, but hooking the link into thesis_hook_after_post instead of the archive intro filter. I would probably need an outline of the taxonomy/post structure and a working test site to give you the exact code, but I hope that gets you on your way.

  40. Eric Irwin says


    Great information here but there is a way to accomplish much of this without custom PHP code.

    I found a nice plugin I used on a Thesis site I created for a client. The plugin is called Custom Post Type UI and it allows you to create custom post types and custom taxonomy’s dynamically and then manage them after they have been created. I did have to use the code found on fairinspace.com to enable the Thesis meta boxes – that was the only part that required custom PHP.

    I used this to create a custom post type called “episodes” for The Dr. Karen Show so new episodes could be added separately and as easily as a new blog post.

  41. says

    Eric — Thanks for pointing the plugin out. I have a weird aversion to plugins; I avoid them where possible. Perhaps because I don’t like being dependent on other developers, when I’m not sure if they’re going to keep stuff up to date etc. And I like to understand what’s going on with my website and I want others to understand it too… I like that plugin though, it is in essence providing an interface for the PHP in this post (as the name suggests — providing a UI).

  42. Eric Irwin says

    I hear you with regards to being dependent on other developers. I will only install a plugin if it looks like one that will be around a while – I look at how many downloads, author website, last plugin update and any other indicators I can find. If it seems like it is still current and nothing else seems suspicious, I’ll give it a try. I had read your article above when I was working on that site a couple of months ago and also found the post at fairinspace around the same time. I was close to going the PHP route until I came across the plugin.

    Anyway, thanks again for the great article above. Although today is my first day writing comments on your site, I have read some of your technical articles in the past and really appreciate how you help the Thesis community!

  43. says

    As always a great post Kris. I have started exploring on the Custom post types for a few of my projects and this came in time to help.

    Another one goes into my Thesis Theme Resources Bookmark :)

  44. says

    Avi — You can just copy and paste that code wholesale into your custom_functions.php file. What it does is change “post” to “book” in the admin, so when you publish or update a custom post type called “book” in the admin it says “book updated” instead of “post updated” in the yellow message box that appears.

  45. Niraj says

    i have a plugin called taxonomy-terms-list, it is used to display the custom taxonomies next to the post, first problem which i faced was, that the position of displaying the taxonomies is not changed, i changed it and i am satisfied with that i used shortcode API in it, but the next problem is the alignment, i am able to adjust the alignment, check the image
    in this mba_courses and Location are not in proper order, i tried table tag but not getting perfect in it,

    the plugin code will include all the custom taxonomies, but if i just want to display certain custom taxonomies then how can i do that?
    this will make me to display and align them in proper order here is the code

    if( !function_exists( 'pr' ) ) {
    function pr( $var ) {
    print '’ . print_r( $var, true ) . ”;

    if( !function_exists( ‘mfields_taxonomy_terms_list’ ) ) {

    function mfields_taxonomy_terms_list( $c ) {
    global $post;
    $o = ”;
    $terms = array();
    $lists = array();
    $custom_taxonomy_names = array();
    $custom_taxonomies = mfields_get_custom_taxonomies();
    if( !empty( $custom_taxonomies ) )
    foreach( $custom_taxonomies as $name => $config )
    $custom_taxonomy_names[] = $config->name;
    if( !empty( $custom_taxonomy_names ) )
    $terms = get_terms( $custom_taxonomy_names );
    foreach( $custom_taxonomies as $name => $config )
    $o.= get_the_term_list( $post->ID, $name, $before = ” . $config->label . ‘: ‘, $sep = ‘, ‘, $after = ” );
    if( is_single() )
    return $c . $o;
    return $c;
    add_shortcode(‘terms’, ‘mfields_taxonomy_terms_list’);

    if( !function_exists( ‘mfields_get_custom_taxonomies’ ) ) {
    function mfields_get_custom_taxonomies( ) {
    global $wp_taxonomies;
    $custom_taxonomies = array();
    $default_taxonomies = array( ‘post_tag’, ‘category’, ‘link_category’ );
    foreach( $wp_taxonomies as $slug => $config )
    if( !in_array( $slug, $default_taxonomies ) )
    $custom_taxonomies[$slug] = $config;
    return $custom_taxonomies;


  46. says

    Niraj — This is not what I meant when I said posting in the forum would be better.

    My inclination is still that this template tag would be better for displaying the taxonomy list. It’s certainly more concise than the code you’ve got there. If you want to use it as a shortcode in the post, then create your shortcode such that it accepts a parameter of the taxonomy name: see the shortcode API for details.

  47. says

    One more help require kristarella
    I have custom posts, which i made through a plugin,
    now what i want is, that this custom posts should be only displayed on a single page which i will name it as a blog,
    how can i do that

  48. says

    Niraj — From this post, you can create a custom query and loop:

    function custom_page_type_folio() {
    	if (is_page('Blog')) { ?>
    		<div id="content" class="hfeed">
    			query_posts(array('post_type' => 'your-post-type', 'posts_per_page' => 5));
    		<div id="sidebars">
    			<?php thesis_build_sidebars(); ?>
    	<?php }
    remove_action('thesis_hook_custom_template', 'thesis_custom_template_sample');
    add_action('thesis_hook_custom_template', 'custom_page_type_folio');
  49. says

    Hey hii,
    i need a help,
    i have custom taxonomies location, courses and duration working on my website,
    if i type http://mbas.in/location/mba-in-usa/ then i get all the posts of USA, but what i want is before displaying the list of these post i want a small content to be shown before all this posts,
    a small description of the corresponding location and then the posts of that location,
    how can i do this?
    but i want this for all the locations, for UK, India, Australia etc

  50. says

    Niraj — I believe that Thesis lends that functionality automatically to taxonomies. If you go the the page for that taxonomy in the dashboard there should be an area to add a description etc.

  51. says

    Ive got this working superbly and I’m incredibly grateful for you blog. I was wondering how I;’d get the socialise plugin working with a custom post type page?

  52. says

    I solved my own problem. I simply turned on comments and the Socialise started working. Now I’m smacking myself for not haveing the ‘more’ feature working I thought that would be excepts ?

  53. says


    thanks for your post, very good info

    Just solved my 2 hour problem with you statement

    “Also, you need to visit the permalink settings page after registering the post type to flush the rewrite rules so the new slugs work (just visit the page, you don’t have to re-save the options).”

    Fixed my 404 errors – thanks!

  54. says

    What about setting up comments for the post?

    I can’t seem to figure it out.

    Is there code I need to add just like the custom SEO and post Image code for comments as well?

  55. says

    hey :)

    How are you? Kristarella, would you know how to link a Header in Thesis_18 with a specific URL?
    I have added a header that is informing about an evenet in the near future and would like to link it with a page, but there is now way of doing this through the Dashboard.

    thank you:)

  56. Yubraj says

    Hi Kris,

    I have three content type or main menus:
    1. Articles,
    2. Resources, and
    3. Videos

    And 4 Topics
    1. Guitar
    2. Drum
    3. Keyboard and
    4. Flute

    I want all of them(4 topics) as a drop down menu which is common for all 3 content type (Articles, Resources, and Videos).

    When I click videos it must link to an aggregation page (view/videos). And when I click on Videos>Guitar it must link to an aggregation page(view/videos/guitar).

    I want all 7 items(Articles, Resources, Videos and Guitar, Drum, Keyboard, Flute) as a primary category.

    How can I set a linkage between Content type and Topics so that when ever i create a new post i can identify its content type and Topic. Then display it on its aggregation page.

    Please Help me.


  57. says

    Yubraj — the the function register_post_type there is a “taxonomies” parameter where you can assign the taxonomies that will be available to that post type. If you are using a Custom Post Type plugin to create the post types there should be a field on the setup page that does the same thing. When the taxonomies are enabled for the post type in this way you will be able to assign the taxonomies to your posts on the edit page.

  58. Yubraj says

    Thanks a Lot Kris,

    I am able to create drop-down menu for 4 topics under the 3 content type using taxonomy and linked them on their respected aggregate pages. But i am unable to link the content type to its aggregate page. Here is my code:

    function article_nav() {
    echo ‘Articles‘;
    echo ”;

    I want to link the Articles to its aggregate page. Please help me.

  59. Mars says

    Hi Kristarella,

    Thank you for the taxonomy meta code in comment# 17, it worked well on one of my site. I’m just wondering though if you can help me on how to output just the term for the taxonomy page to use for meta description. I’m trying to get this result

    Thank you in advance.

  60. jeff says

    Hi Kristarella,

    I really appreciate your blog and have learned a lot. Need some help on my site: DeeringBayCondo.com. When viewed on an Ipad or cell phone, almost half of the content area is cutoff. Any suggestions? Your help is always appreciated.


  61. says

    Hi Kris,

    Thank you for the nice blog posted here. I think I have grasped a lot of new things. I just had one challenging question and wanted to find out if you were or are able to resolve this. I have a set of custom post types, pertaining to real-estate MLS (e.g. list type, neighborhood type, etc.).

    I have also been able to develop a set or collection of custom templates directly associated with these post types. Now the challenge I have is dynamically loading these custom templates to generate custom posts of these type (post type). I am using Thesis18 and WP 3.1. Can you help me how I can achieve this, or show me something?

  62. says

    Freddie — There’s two ways (just using the regular custom folder, or using a child theme), but both probably will use the Thesis Custom Loop API.

    Except the custom loop API doesn’t have a class hook for custom post types, so you might need that in combination with a child theme and post templates that are essentially the same as Thesis’ index.php or no-sidebars.php, then you put the template into your functions file and hook it into the API. Hope that makes some sense!

  63. says

    Thank you Kris for the immediate response. This does make some sense I would say, but to fully grasp what you have just pointed out, it would be wonderful to see an example of this implementation, as I have tried all ways possible even looking up the Thesis Custom Loop API but keep on banging my head on the wall.

    Would you by any chance know of an implementation like this that achieves what I want to do, perhaps I could dig into some code samples to fully grasp what you are explaining. Appreciate all the help here by the way.

  64. says

    Freddie — Actually you probably don’t need any custom template files, just conditional tags. Then use code like this:

    class my_loops extends thesis_custom_loop {
    	function single() {
    		if ('neighbourhood-type' == get_post_type()) {
    			// Actual loop code removed for clarity
    	function archive() {
    		if (is_post_type_archive('neighbourhood-type')) {
    			// Actual loop code removed for clarity
    $loopty_loop = new my_loops;
  65. says

    Thank you Kris, for the sample code piece. I will go through this and update should I run into any issues or be successful. Thank you again.

  66. says

    very useful post..anyways i am looking for showing up related post for custom post types using tags…any help is appreciated!!

  67. Gary says

    Hey Kristarella – when I use the code you shared in #9 to get the dropdown menu of custom taxonomy, it works great. I’m trying to figure out how to just get a list of the custom taxonomies with links that isn’t in a drop down? They give an example on the get_terms() documentation, but I’m not even having luck getting the list of terms without links using their examples. Can you share how to change the code on #9 to just list the links available?

  68. says

    Gary — The following should give you a list of linked taxonomies:

    $taxes = get_terms('TAX','hide_empty=0&hierarchical=0');
    echo '<ul>';
    foreach ($taxes as $tax) {
    	echo '<li><a href="' . get_bloginfo('url') . '/TAX/' . $tax->slug . '">' . $tax->name . '</a></li>';
    echo '</ul>';

    You should only need to change the capital ‘TAX’ bits to the name of your taxonomy.

  69. Gary says

    Thanks Kristarella. This has become a good learning experience as I found a plugin that works well… but my preference is to not use plugins. I really appreciate your tutorials they helped me on many different occasions during this process.

  70. says

    I’ve been using the Thesis meta box code since last year (thanks!), and within the last week started seeing a conflict in WP 3.3 between the code and the ability to upload images through NextGEN Gallery. When using the Flash uploader in NextGEN I see “HTTP error” or “IO error”, depending on which browser I’m using.

    When checking my error logs I saw the following:

    PHP Fatal error: Class ‘thesis_post_options’ not found in /var/www/html/wp-content/themes/themename/custom/custom_functions.php on line 444, referer: http://www.domain.com/wp-inclu......flash.swf

    Removing your code resolves the problem, adding it back in re-introduces the problem.

    Note: Before posting this I did a little more troubleshooting, and found that wrapping the meta box code in the following works by restricting it to specific pages. In this instance, the post.php and post-new.php pages.

    global $pagenow, $page;
    if ( ‘post.php’ == $pagenow || ‘post-new.php’ == $pagenow ) {

  71. Katie says

    Hi Kristarella – can you help me dress up the new posts under my new custom post to have a different look than the general blog posts?

    Let’s call my custom post Properties. When someone goes to a single page under Properties /properties/single-post-here, I want this to look different from my other single post template. Is that possible?

    Thank you.

    • says

      Katie — Yes. There’s a number of ways to do it, including theme template files, CSS, and more in Thesis. Are you using Thesis? In what way do you want Properties to look different?

  72. Katie says

    Wow! I was just hoping you’d reply. Yes, we are using Thesis 1.8. I can style it with CSS but I want to edit the single post template by adding more class. On the new template that I want, I want the sidebar to be inside the id content. Thank you!




    If you can just point me how to re-create a new single post page and assign it to my custom post, I may be able to figure out how to add the rest. Or whatever you can send my way, I’ll appreciate it very much!

  73. Katie says

    Oops sorry.
    [div id=content][end]
    [div id=sidebars][end]

    [div id=content newclass]
    article here

    So on the second post template, I want the sidebars to be inside the div content, not outside.


  74. Martin says

    Hi I love your posts and they are all very informational and i have even used some of your tutorials on my pages. I have a little problem thou and i can not seem to find any solution on the net maybe no one needed this before.Do you know how can i make posts to be displayed as links only ?? For example i have a page named Category and i have all of my categories there and when a visitor clicks on a certain category i want all the posts in that category to be displayed to them as short links. This is because i have a big number of posts and by default the posts are displayed as titles and the list down is very big .. So is it possible for the posts be displayed as links and all of them to be put on the page after clicking the category?? Thank you in advance

  75. says

    Hi Kristarella,
    I want a little of style on my website and I need to define colors (colours), I’m planning on choosing between 5/7 color that are going to be on the page, font, background etc. Could you please help me out with that. Right now I’m very cluttered with the nav manu etc. I know I’m going to use the font color I’m using right now, and Iwant to use some kind of blue, some white and brown & of-course blue black or 805 black for paragraph fonts etc.
    Thanks for you help.

  76. says

    I do not even know how I stopped up right here, however I believed this submit used to be good. I don’t know who you are but certainly you’re going to a well-known blogger if you happen to are not already. Cheers!

  77. says

    Thank you for this excellent tutorial! I’ve used in many times designing sites with Thesis.

    I have been unable to find an answer to one problem though. Do you know how to include a custom taxonomy (specifically, a custom hierarchical taxonomy) in the Thesis nav menu? I haven’t ever been able to get my custom taxonmies to show up as choices in the Thesis menu manager (only the Categories taxonomy shows up). And while the Thesis nav menu supports adding links to the menu; it only allows links to be added as parent-level menu items. We can’t add links as child-menu items, say as a drop-down menu group for a hierarchical custom taxonomy.

    Thank you for any help you can provide.

  78. says

    Colleen — You could do it via PHP to hook into thesis_hook_last_nav_item, but I would recommend using the WordPress menu system, which Thesis has supported for about a year, and soon Thesis will be deferring completely to that system. It’s a lot more flexible and allows addition of custom taxonomies when present.

  79. johnny_n says

    @Jeremy Henricks – I couldn’t get your code to work, but for others with the same problem, this code worked perfectly for me (using the example in the post above):

    function custom_thesis_meta_boxes() {
    $post_options = new thesis_post_options;
    foreach ($post_options->meta_boxes as $meta_name => $meta_box) {
    add_meta_box($meta_box[‘id’], $meta_box[‘title’], array(‘thesis_post_options’, ‘output_’ . $meta_name . ‘_box’), ‘zombie’, ‘normal’, ‘high’);
    add_action(‘save_post’, array(‘thesis_post_options’, ‘save_meta’));

    From here: