• Just wondering if there is a way to remember the taxonomy term when viewing a post if you came through a taxonomy listing page.

    for example i have a custom taxonomy called ‘sectors’ in this i have ‘commercial’, ‘education’ and ‘health’

    I have a custom post type called casestudies and have a case study setup and have given it the taxonomy ‘commercial’ AND ‘health’

    If i go to:
    /sectors/health

    sectors-taxonomy.php kicks in and my case study is listed. If i then click on this case studiy it loads the post using single-casestudy.php

    However I would like to know within the code of single-casestudy.php that i came through via ‘health’ so i can show other case studies in the health taxonomy on the page. I am not interested that it also has the commercial one.

    Is there a neat way to carry this over? In traditional development you’d put the category in the querystring or in a cookie so the details page could use it to drive those kinda things.
    e.g. you are on something likse listcase.php?category=2 and the link to the case study would be /viewcase.php?id=1&category=2.

    I could do this in WordPress or use a cookie, but i thought there might be a more elegant way to do it?

Viewing 1 replies (of 1 total)
  • Thread Starter latro666

    (@latro666)

    Guess thats a no then :(.

    For future searchers i just bodged it with cookies:

    On taxonomy listing:

    <?php
    $curtax = $wp_query->queried_object->term_id;
    setcookie("curtax", $curtax, time()+3600, '/');
    ?>

    Then the next page can access that cookie to workout what the taxonomy the user came in from.

Viewing 1 replies (of 1 total)

The topic ‘Remembering taxonomy term when viewing post’ is closed to new replies.