Support » Themes and Templates » Get Category URL
6 years ago
Hi, If I’m on a category page.. example.com/category/2 and I want to place that url in a meta tag on the same page, how do I call that url?
I’ve tried category_description() category_id() etc etc but none work or they show blank (because it’s outside the loop).
I’ve searched over 20 blogs for an answer to no avail.
Basically, I need to put the current category url into a meta tag ON THAT SAME url.
I appreciate any help.
I don’t know if there is a function within WP that does this, but <?php echo $_SERVER['REQUEST_URI'] ?> should do what you want.
<?php echo $_SERVER['REQUEST_URI'] ?>
Alas that adds the url but as a hyperlink. I need the raw url output.
Thanks anyway, Veganist, you’ve put me on the right track.
There are other options that could fit : http://php.net/manual/en/reserved.variables.server.php