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.
<?php
$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>
<?php
}
echo '</ul>';
?>
Thanks,
Lorne
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: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:See: http://codex.wordpress.org/Function_Reference/get_the_term_list