Tagged: advanced layout, Portfolio, portfolio tags, Tags
Hi Guys,..
Looking for a solution. We wanted to show portfolio tags on our portfolio pages built with advanced layout. We’ve installed code per this solution. Problem is, although the tags do show up on the page, the sort function is not working. Meaning when a user clicks on the chosen tag link, they are not taken to a page that lists all the items with that tag. They are instead taken to the top of the page.
The code we’re using:
function show_portfolio_tags_func() {
global $post;
$the_tags = get_the_tags( $post->ID , 'portfolio_entries');
$output = '';
foreach($the_tags as $tag) {
$taglink = get_tag_link($tag->tag_id, $tag->taxonomy);
$output .= '<span class="portfolio_tag"><a href='.$taglink.'>'.$tag->name.' </a></span>';
}
return $output;
}
add_shortcode('portfolio_tags', 'show_portfolio_tags_func');
What is the correct code?
Hey Diana,
Thank you for using Enfold.
Try to remove the “portfolio_entries” taxonomy in this line.
$the_tags = get_the_tags( $post->ID , 'portfolio_entries');
And in the following line, remove the second parameter $tag->taxonomy.
$taglink = get_tag_link($tag->tag_id, $tag->taxonomy);
Those functions only accept post and tag id as the parameter.
// https://codex.wordpress.org/Function_Reference/get_tag_link
// https://codex.wordpress.org/Function_Reference/get_the_tags
Best regards,
Ismael