WordPress.org

Ready to get started?Download WordPress

Forums

Get Category URL (4 posts)

  1. Lou Sparx
    Member
    Posted 3 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.

  2. curlybracket
    Member
    Posted 3 years ago #

    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.

  3. Lou Sparx
    Member
    Posted 3 years ago #

    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.

    Lou

  4. curlybracket
    Member
    Posted 3 years ago #

    There are other options that could fit : http://php.net/manual/en/reserved.variables.server.php

Topic Closed

This topic has been closed to new replies.

About this Topic