get_the_tag_list( string $before = '', string $sep = '', string $after = '', int $post_id = 0 ): string|false|WP_Error
- Since
- 2.3.0
- Source
wp-includes/category-template.php:1205
Compatibility
- WordPress
- since 2.3.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$beforestringoptional- String to use before the tags. Default empty.Default:
'' $sepstringoptional- String to use between the tags. Default empty.Default:
'' $afterstringoptional- String to use after the tags. Default empty.Default:
'' $post_idintoptional- Post ID. Defaults to the current post ID.Default:
0
Return value
string|false|WP_Error- A list of tags on success, false if there are no terms, WP_Error on failure.
Performance profile
How much work a call to get_the_tag_list() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 21
- Plugin surface
- 1 hook
- Called by
- 9
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 21.
Third-party callbacks on 'the_tags' run inside this call, and their cost is not bounded by anything here.
9 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach query, cache, option, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_the_tag_list() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 21 | get_the_term_list(), apply_filters() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 21 instructions, 21 executed per call, 0 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while get_the_tag_list() runs, in this order:
Uses · 2
- get_the_term_list()Retrieves a post's terms as a list with specified format.
- apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 9
- the_tags()Displays the tags for a post.
- twenty_twenty_one_entry_meta_footer()Prints HTML with meta information for the categories, tags and comments.
- twentyfifteen_entry_meta()Prints HTML with meta information for the categories, tags.
- twentynineteen_entry_footer()Prints HTML with meta information for the categories, tags and comments.
- twentyseventeen_entry_footer()Prints HTML with meta information for the categories, tags and comments.
- twentysixteen_entry_taxonomies()Prints HTML with category and tags for current post.
- twentyten_posted_in()Prints HTML with meta information for the current post (category, tags and permalink).
- twentythirteen_entry_meta()Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
- twentytwelve_entry_meta()Sets up post entry meta.
Source code
function get_the_tag_list( $before = '', $sep = '', $after = '', $post_id = 0 ) { $tag_list = get_the_term_list( $post_id, 'post_tag', $before, $sep, $after ); /** * Filters the tags list for a given post. * * @since 2.3.0 * * @param string $tag_list List of tags. * @param string $before String to use before the tags. * @param string $sep String to use between the tags. * @param string $after String to use after the tags. * @param int $post_id Post ID. */ return apply_filters( 'the_tags', $tag_list, $before, $sep, $after, $post_id );}Changelog
Introduced in 2.3.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/category-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.