I have to insert some condition if the current page is a category page or not.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
I have found the way to do it by checking if
$cat_id
is available or not on that page by the following.Now we can check if $cat_id is available then it is a category page otherwise it is not.
Amit's answer will work but there is a simpler way as Wordpress sets a Global var for the category id of $cat. So just checking if this is set will tell you if you are on a category page.
you can use this for getting category
You can use
function.
refrence: http://codex.wordpress.org/Function_Reference/is_category