[wp-trac] [WordPress Trac] #30705: Add parameter to get_the_term_list() to allow templating
WordPress Trac
noreply at wordpress.org
Sun Mar 23 04:36:01 UTC 2025
#30705: Add parameter to get_the_term_list() to allow templating
------------------------------------------+---------------------
Reporter: davidjlaietta | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Taxonomy | Version: 2.5
Severity: normal | Resolution:
Keywords: has-unit-tests needs-refresh | Focuses:
------------------------------------------+---------------------
Comment (by wildworks):
It is of course possible to display terms related to a post without links.
For example:
{{{
<?php
$terms = get_the_terms( get_the_ID(), 'taxomomy_name' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) :
?>
<ul>
<?php foreach( $terms as $term ) : ?>
<li><?php echo esc_html( $term->name ); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
}}}
Wouldn't it be convenient if we could achieve the same thing with code
like this:
{{{
echo get_the_term_list(
get_the_ID(),
'taxomomy_name',
'<ul><li>',
',</li><li>',
'</li></ul>',
'%2$s' // Default is `<a href="%1$s" rel="tag">%2$s</a>`
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30705#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list