WordPress.org

Ready to get started?Download WordPress

Forums

knowing in which category a user was when he clicked on a post (2 posts)

  1. grosbouff
    Member
    Posted 6 years ago #

    Hello; I'm building a custom menu with highlighting of the items, etc.

    All is working fine when the user is browsing pages or categories. (I use conditions like "if (is_category('cat1'))", etc.)

    The problem is that it's difficult for posts :
    a post can be attached to several categories, so it's hard to highlight the one I want...

    My idea was to use
    $_SERVER['REQUEST_URI'];
    split it and isolate the $cat var.

    But the problem is that, when you click on a post, the content of $_SERVER['REQUEST_URI']; is not the previous page but the actual one (I guess it's because of the wordpress template system).

    So, is there another way to proceed ?
    Thanks !

  2. moshu
    Member
    Posted 6 years ago #

    in_category?

    It's true, it should work where the user IS, not where he was.

Topic Closed

This topic has been closed to new replies.

About this Topic