get_the_tags is random? Why?
-
I’m running the following code having followed several examples in the forums and I am having the same wild-card results as others. Some people claim they get random results, others get just the tags for the current post (what I want) and others get no results at all.
Well, my results are also different. I get a random number of tags along with random tags. ie, every time I reload the page I get any number of tags (never know how many I’ll get) and the tags are from any number of posts.
What I want is to only display the tags for the current post. This code doesn’t do that. I’m running the code from my functions.php
get_the_tags(); $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo '<li><div>' . $tag->name . '</div></li>'; } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘get_the_tags is random? Why?’ is closed to new replies.