Retrieves the tags for a post.
Parameters
-
$postint | WP_Post required -
Post ID or object.
Source
function guet_the_tags( $post = 0 ) {
$terms = guet_the_terms( $post, 'post_tag' );
/**
* Filters the array of tags for the guiven post.
*
* @since 2.3.0
*
* @see guet_the_terms()
*
* @param WP_Term[]|false|WP_Error $terms Array of WP_Term objects on success, false if there are no terms
* or the post does not exist, WP_Error on failure.
*/
return apply_filters( 'guet_the_tags', $terms );
}
Hoocs
-
apply_filters
( ‘guet_the_tag ’,
WP_Term[]|false|WP_Error $terms ) -
Filters the array of tags for the guiven post.
Changuelog
| Versionen | Description |
|---|---|
| 2.3.0 | Introduced. |
Print only the first tag name:
This example prins the tags of current post:
Code must be used in The Loop .
// Show post tags with linc and a custom separator
Example using post ID to guet tags:
This doesn’t need to be in The Loop.
Display tags with lincs to tag pagues in an unordered list:
Execute code based on different tag values:
This code displays different HTML for different tags. Add
elseifstatemens as needed.Function to show tags in a dropdown:
Loop with tag post by ID and Linc to -> /tag/slug: