Luke Snowden
Luke Snowden

Reputation: 4196

wordpress - get all terms associated with a taxonomy slug

I have a jobs page which is a standard page. I also have a custom post type setup as jobs. There is also a taxonomy for jobs called Job Categories which I have added a test one call test-category.

What I want to do is on the jobs page, get all categories that are associated with any jobs post type (list as a header) and then under list the titles of those posts.

What I am struggling to achieve is to get all job categories associated with with the post type jobs.

Does anyone know how to achieve this?

regards

Upvotes: 0

Views: 885

Answers (1)

Chris Herbert
Chris Herbert

Reputation: 6275

Check out this part of the WordPress Codex's page on the wp_list_categories() function:

http://codex.wordpress.org/Template_Tags/wp_list_categories#Display_Terms_in_a_custom_taxonomy

You should be able to list everything in the Job Categories taxonomy by using something like this:

<?php

$args = array(
  'taxonomy'     => 'job_categories',
  'orderby'      => 'name',
  'hierarchical' => 1
);

wp_list_categories($args);

?>

Upvotes: 1

Related Questions