php - Wordpress Get the CURRENT Category from Single Post, Multiple Categories
I've got a Custom Post Type of Home Plan and a Custom Taxonomy of Community.
The same Home Plan appears in multiple different Communities.
Permalinks have been set, and now I'm trying to find the current Community from which I'm viewing the Home Plan.
Because the Home Plan appears in multiple Communities, the following example links all take you to the same Home Plan as intended:
In order to display the relevant information based on the Community, I'm attempting to find a way to determine the current Community.
In my single-home-plans.php file, I've printed get_query_object(); and get_the_terms(); but I haven't found anything useful.
A possible workaround would be to pass a $_GET value, but at this point that's an absolute last resort.
No such thing as current taxonomy, when you on single page. You can only check from which taxonomy user go to this page. You can do this by checking $_SERVER['HTTP_REFERER'].
Assuming your url are as simple as what you've provided, this will probably do,
query_varis set to
truein the taxonomy, you can detect which category is currently being viewed by using
var_dump($wp_query->query_vars);to view the full array of all query information.