I have my portfolio setup – everything working great so far! I click an item in my portfolio grid, it goes to the page of the portfolio item. This page didn’t have the title of the portfolio item so I added that functionality in loop-page.php. But I can’t figure out how to add a link back to the category main gallery (placed below the title I have added). For example I have a portfolio of Dogs. I click the Labrador item and at the top of this Labrador item I would like to have a link back to Dogs (or whatever category the item may belong to).
I’ve tried the code below in loop-page.php but this portfolio category must be accessed some other way?
$category = get_the_category(get_the_ID());
if($category[0]){
echo ‘term_id ).'”>’.$category[0]->cat_name.’‘;
}
Hey karirak73!
If your wanting the link to display on the single portfolio post view then the file your looking for is loop-portfolio-single.php. Stuff you add in there will display on the portfolio posts.
Best regards,
Elliott
Hey Elliott,
I’m not having any trouble getting things to display in the right spot (I already got the title of the portfolio item to display, no problem). I’m having trouble getting the “portfolio category” of the current portfolio item. If I’m on a portfolio item page (Labrador for example) how can I access/find out the category that “Labrador” belongs to (i.e. Dogs) on the loop-portfolio-single.php page? If I can know this information I will be able to create the link and get it in the page. Just need the portfolio category ID or name or something??
Thanks!
Hey!
You would use the wp_get_post_terms function, http://codex.wordpress.org/Function_Reference/wp_get_post_terms.
Something like this.
$terms = wp_get_post_terms( $post->ID, 'portfolio_entries' );
foreach ( $terms as $term ) {
echo $term->name;
}
Cheers!
Elliott
Thanks very much! That is the function I needed.
Hey!
glad Elliott could help. Let us know in a new ticket if you have any more questions related to the theme. We are happy to assist.
Best regards,
Andy