-
AuthorPosts
-
July 8, 2015 at 3:02 am #470014
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.’‘;
}July 8, 2015 at 5:40 pm #470426Hey 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,
ElliottJuly 8, 2015 at 7:53 pm #470509Hey 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!July 9, 2015 at 3:00 pm #470924Hey!
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!
ElliottJuly 10, 2015 at 2:13 am #471233Thanks very much! That is the function I needed.
July 10, 2015 at 3:17 pm #471495Hey!
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 -
AuthorPosts
- The topic ‘Need to add a link back to portfolio category in portfolio item page’ is closed to new replies.
