I would like to get all the post tags in my WordPress. Below is my code in the footer:
<?php
global $wpdb;
$tags = get_terms('post_tag');
echo '<ul>';
foreach ($tags as $tag)
{
echo '<li>' . $tag->name . '</li>';
}
echo '</ul>';
?>
With the above code I am getting only the tags associated with a specific post, not the entire list of tags in WordPress.
Any help will be appreciated. Thanks.
Use get_tags to get all posts tags
<?php
$tags = get_tags(array(
'hide_empty' => false
));
echo '<ul>';
foreach ($tags as $tag) {
echo '<li>' . $tag->name . '</li>';
}
echo '</ul>';
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With