I'm putting simple breadcrumbs in a site, based on a custom post's category.

Items > Category > Individual Post

"Items" doesn't change, it's just plain text.

In the Category page it's title is coded like this.

$term = $wp_query->queried_object;
$cat_title = $term->name;

An Individual post can have more than one category so I need to keep a track of which category the user clicked through to get to a detail page.

What's the best way to pass $cat_title and it's slug (to make the URL) to a detail page?

In the case where a user does a search and goes directly to a detail page, I assume I can check if this title is set, if not then I pull the first category it belongs to.

  • 1
    possible duplicate of Get default permalink structure from pretty URL's Dec 22 '14 at 4:27
  • That helps. While I knew there were several questions that might answer my question I didn't know which was best. That looks like a very simple answer. What do I do with this question now that a comment has answered it?
    – strattonn
    Dec 22 '14 at 7:05
  • use php session.it should works
    – jewelhuq
    May 1 '15 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.