Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Create a category-style page from taxonomies (custom post types) WordPress


I've been looking around the web, and I can find a certain amount of info, but can never quite get the full info I need.

What I need to do, is have a category page for each of my post types. I have sections such as One Day Courses, Weekend Courses, Articles, News, Publications, Links, etc.

From reading around online, it seems that I need to have taxonomies attached to the post type, and this will then be what is used for the category page. I also have hierarchal set on the taxonomy, as it looks like this is also what I require to make it work as a category rather than as tags.

All this is set, all I need to know is how I set up a page for each post type, so people can get a list of the courses, articles, news, etc, just as they would if they were normal categories.

If this could be alphabetical, then that wuld be a bonus, but not as important as just getting the categories done. I need to get this done today if possible (deadline).

If this helps, when I set up the custom post type, itdoes give me some embed code, but I ahve no idea what it does, or where it goes. This is for the taxonomy called <strong>'1daytax'</strong> which is attached to a custom post type called <strong>'1day'</strong>:

<?php echo get_the_term_list( $post->ID, '1daytax', 'Before: ', ', ', 'After' ); ?>

Answers (1)


Ivaylo Draganov answers:


if custom post type archives is what you basically need, then you already have it in WP:
[[LINK href=""]][[/LINK]]

But it has to be enabled when registering the post types:
[[LINK href=""]][[/LINK]]

According to the template hierarchy, WP will use <em>archive.php</em> for displaying the post type archives. But if you want to have some more radical changes in the display of those archives, then you can copy <em>archive.php</em> to a file called <em>archive-{post_type}.php</em> (replacing <em>{post_type}</em> with the slug of your post type) which will be used over the default template.

You could use that new template file to change the order of posts. For example, to order them alphabetically put this at the top of the file:

<?php query_posts('orderby=title&order=ASC'); ?>

As for this piece of code:

<?php echo get_the_term_list( $post->ID, '1daytax', 'Before: ', ', ', 'After' ); ?>

From [[LINK href=""]]the Codex page[[/LINK]]:
Returns an HTML string of taxonomy terms associated with a post and given taxonomy. Terms are linked to their respective term listing pages.

Joe Jenkins comments:

I'm having a blonde day, so apologise if this is a stupid question, but what would the url be:

I tried & (the category in the taxonomy is tisi).

No luck though. I know this is simple, but for some reason sense is eluding me.

Ivaylo Draganov comments:

Try resaving your permalinks (under "Options > Permalinks").

But keep in mind that post type archove and taxonomy archive are not the same. The url depends on the slug of the taxonomy, so try something like:

Joe Jenkins comments:

Thanks, I got it working in the end with on the 2010 theme, which gives me a starting point.

Thanks for the help.

Joe Jenkins comments:

I clicked to assign the prize, but it has a weird voting thing since I last used the site.

That should go through though, as far as I can see, but I'll send a message to the site and check.