Hi,
i would like to add tags below my post. If poissible automaticly or with shortcode?
How ca i do that?
Kind regards
Jak
Hey Jak73,
Thank you for the inquiry.
You can use the following snippet in the functions.php file to create a custom shortcode that renders the post tags.
/* shortcode to render post tags */
function post_tags_shortcode()
{
global $post;
$tags = get_the_tags($post->ID);
$separator = ' ';
$output = '';
if (!empty($tags)) {
foreach ($tags as $tag) {
$output .= '<a href="' . esc_url(get_tag_link($tag->term_id)) . '" alt="' . esc_attr(sprintf(__('View all posts in %s', 'textdomain'), $tag->name)) . '">' . esc_html($tag->name) . '</a>' . $separator;
}
}
return trim($output, $separator);
}
add_shortcode('sc_tag_category', 'post_tags_shortcode');
You can now use the [sc_tag_category] shortcode to display the tags inside the post.
In the advance layout builder, add a code or text block, then use the [sc_tag_category] shortcode to render the tags.
Best regards,
Ismael
Hi Ismael,
thank you very much, i will try that.
Kind regards Jak
Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan Shannon
Hi Jordan,
yes, some more help needed.
How can I style the tags to the enfold portfolio theme. Would be nice, when I have a more like a button style for the tags?
Kind regards Jak