Posted in WordPress · January 9th, 2011 by Kazim · Comments (0)
Basically I was looking to grab WordPress post tags in a PHP variable to show related posts. I wasn’t able to search a perfect article with a very short code to do it. Well here’s it after all.
<?php global $post; $tags = wp_get_post_tags($post->ID); ?>
You can use the above code in “while” or any where. You just need to through the post ID. We need to global the post variable to get the exact post ID. This code is throwing your side an array. So by it you can simply sort things out very easily such as using it in a variable, use foreach to echo either there are things more out to do such stuff. Some people use wordpress tags in URL to get more traffic. Where as this include the tags and by search engine there is more traffic coming your way by the URL. Hopefully this would have helped. I will be posting more to grab things in variable in wordpress. Such as grabbing title in a variable or grab a wordpress title in a variable.
No comments yet