我已经找到了通过以下方式检查$cat_id该页面是否可用的方法.
$cat_id = get_query_var('cat');
Run Code Online (Sandbox Code Playgroud)
现在我们可以检查$ cat_id是否可用,然后它是一个类别页面,否则它不是.
您可以使用
is_category();
Run Code Online (Sandbox Code Playgroud)
功能。
参考:http : //codex.wordpress.org/Function_Reference/is_category
小智 6
你可以用它来获取类别
is_category();
is_category( '1' ); // where 1 is category id
is_category( 'test' ); // where test is category name
is_category( 'test-ing' ); // where test-ing is category slug
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29954 次 |
| 最近记录: |