Get current category id from post page wordpress
WordPress has a function wp_get_referer, which gets the referring url from the http-header. So, if you go from a category archive to a single post, the name of the category will normally be included in that url. This means you can start your single.php like this: $refer = wp_get_referer(); if (strpos($refer, ‘category/cat1’) != false) {… … Read more