WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have our portfolio page here: http://www.slarc.com/portfolio-view/central-control-building-east-texas/

The orange links below the project title are manually inserted on the page content. Is there a way to call in a the post categories to make this automatic?

The template I'm using doesn't have our portfolio posts under WP Posts. It's under a custom post-type titled "Portfolio".

I have received this code below. But I don't know how to add it to my page. When I tried everything on the page below the PHP code disappeared.

$args = array( 
    'type'                     => 'post', 
    'child_of'                 => 0, 
    'parent'                   => '', 
    'orderby'                  => 'name', 
    'order'                    => 'ASC', 
    'hide_empty'               => 1, 
    'hierarchical'             => 1, 
    'exclude'                  => '', 
    'include'                  => '', 
    'number'                   => '', 
    'taxonomy'                 => 'your_custom_taxonomy', 
    'pad_counts'               => false ); 
$categories = get_categories($args); 

echo '<ul>'; 

foreach ($categories as $category) { 
    $url = get_term_link($category);?> 
    <li><a href="<?php echo $url;?>"><?php echo $category->name; ?></a></li> 

echo '</ul>'; 

Thanks, Lorne

share|improve this question

It's hard to be sure without knowing what Taxonomy the "Portfolio" post type is using. Even though it's a different post type, it might still be using the default category taxonomy. If it is, then you don't need to use get_categories(); as you're doing above. The following should work:

<?php get_the_category_list('|'); ?>

The reason your code doesn't work is because 'your_custom_taxonomy' isn't a valid taxonomy. You can always turn on debugging in WordPress to show you any errors that are popping up, instead of just seeing a blank page.

For more info, see get_the_category_list and get_categories.

If you're trying to display only the terms that are applied to a given post (not all of the categories available), for a taxonomy portfolio_category, try the following:

<?php echo get_the_term_list( $post->ID, 'portfolio_category' ); ?>

See: http://codex.wordpress.org/Function_Reference/get_the_term_list

share|improve this answer
Thanks for the reply. However that didn't work? I need to turn on debugging and try to get to the bottom of this. I think it's a custom post type and not a custom taxonomy. But I didn't make this template, where do I find that out? – lorne17 Feb 27 '13 at 14:58
It might be a custom post type using a custom taxonomy. This is a little more complex than I can explain here. You might want to read codex.wordpress.org/Post_Types, and codex.wordpress.org/Taxonomies. Generally you can figure out the taxonomy by going to wherever you set up the post categories in the backend and looking at the URL. If it's a custom taxonomy the URL will end with something like edit-tags.php?taxonomy=custom_cat&post_type=custom_type – bcorkins Feb 27 '13 at 15:03
Ok so I got it to pull in the post categories. Turns out it was a custom taxonomy named: portfolio_category. I used teh code above and changed the taxonomy name. However it pulls in ALL my categories, even if they are unchecked in the edit post page? I have tried hide_empty to both 1 and 0. Neither made an impact. – lorne17 Feb 27 '13 at 17:46
I didn't realize you were trying to list the applied terms, and not all terms. See my edit above. – bcorkins Feb 28 '13 at 0:17
Thanks for the reply...the get_the_term_list worked great. However as with everything else I do in web design I want to through a curveball in the mix. I am getting the links working on this page for "portfolio_category" here: slarc.com/portfolio-view/central-control-building-east-texas However if you look at the link for Administration Buildings it returns this link for the category: slarc.com/portfolio_category/administration-buildings I have a specific page I want to direct it to: slarc.com/projects/administration-buildings How can I do this? – lorne17 Feb 28 '13 at 15:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.