I’ve searched but can’t find the answer but the use case with this, this time round, is that I want to display a single wp ‘tag’ term (out of many applied).
NB {post_terms_post_tag:plain} is great for showing terms (without links, which I also need) but I have content with multiple tags and only have room to display one of them.
Free ice-cream to anyone who knows. I’ll send it in the post!
Since i had to do this quite often, i created a little composer package that is open source to ease the whole process:
Potential code for your problem could look like this:
add_action('init', function() {
juvo\Bricks_Dynamic_Data_Tags\DDT_Registry::getInstance()
->set('single_post_tag', 'Single Post Tag', 'Post Tags', function($post) {
$tags = get_the_tags($post->ID);
if ($tags && !is_wp_error($tags)) {
// Get the first tag or implement your own logic to choose a tag
return '<a href="' . get_tag_link($tags[0]->term_id) . '">' . esc_html($tags[0]->name) . '</a>'; // Change index if you want a different tag
}
return '';
});
});
Thanks @JUVO. Much appreciated. Ice-cream in the post - and I’ll ask Bricks if they can add direct then too, as other systems such as crockblock/elementor have that built-in - assuming there is no other way direct Bricks way to do this - but thanks for the tip/reply.