• Hi
    Which wp function can I use to fetch the category number on a page?
    e.g.
    if url being mydomainname/blog/cat=146, I want to retrieve 146

    Of coarse, it can be done with a preg_match on the $_SERVER[‘REQUEST_URI’] but I like to use custom WP functions.

    Goal: highlight the active class in the WP category list

      by using the current_category= argument.

    thx

Viewing 4 replies - 1 through 4 (of 4 total)
  • You can use the get_query_var() function to do that.

    Thread Starter inigo

    (@inigo)

    Hi vtxyzzy,

    thx for your reply.
    I looked and tried to retrieve the the id by $cat_Id = get_query_var(‘cat’);
    Nope…
    But did I make clear that I am on a page which displays all posts in a certain category? I am not on a post page. It looks like get_query_var is more suitable for that situation.

    grtz I.

    Try using this:

    $cat = $_GET['cat'];
    Thread Starter inigo

    (@inigo)

    YEAH! super simple and working. Great

    BTW I used regular quotes. Otherwise I get errors.

    thx a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘category number’ is closed to new replies.