Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #27822

    Hi, I’d like to display the category under the portfolio item titles… how do I go about this? Tried using get_the_category() in the loop-portfolio.php but it doesn’t work. Help!

    Thanks.

    #135474

    Hi,

    Edit loop-portfolio.php, find this code:

    echo "<h1 class='post-title portfolio-title'>";
    echo "<span class='primary-background title-span'></span>";
    echo "<a href='".get_permalink()."' rel='bookmark' title='".__('Permanent Link:','avia_framework')." ".get_the_title()."'>".get_the_title()."</a>";
    echo "</h1>";

    Replace it with this code:

    $sort_classes = "";
    $item_categories = get_the_terms( $id, 'portfolio_entries' );

    if(is_object($item_categories) || is_array($item_categories))
    {
    foreach ($item_categories as $cat)
    {
    $sort_classes .= $cat->slug.', ';
    }
    }

    echo "<h1 class='post-title portfolio-title'>";
    echo "<span class='primary-background title-span'></span>";
    echo "<a href='".get_permalink()."' rel='bookmark' title='".__('Permanent Link:','avia_framework')." ".get_the_title()."'>".get_the_title()."</a>";
    echo "</h1>";

    echo "<h3 class='portfolio-cat'>";
    echo $sort_classes .= $cat->slug;
    echo "</h3>";

    Use .portfolio-cat to modify the css of the categories.

    Regards,

    Ismael

    #135475

    Hi Ismael,

    Thanks so much for that, I’ve tried the code and it works, except that they show in double (example : Photography, Photography). How do I fix this?

    Thanks,

    #135476

    Oh it’s ok, i got it, instead of

    echo $sort_classes .= $cat->slug;

    it should say

    echo $cat->name;

    Thanks!

    #135477

    Glad that Ismael helped you uncover the answer.

    Enjoy the theme!

    Nick

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Category display under portfolio post titles?’ is closed to new replies.