功能:
is_archive()函数是WordPress的页面判断函数之一,用来判断当前页面是否是存档页面。
用法:
参数:
无
返回值:
(bool) 是存档页面就返回True,否则返回False
所在位置:
is_archive()函数包含在 wp-includes/query.php中.
源码:
/**
* Is the query for an existing archive page?
*
* Month, Year, Category, Author, Post Type archive...
*
* @since 1.5.0
*
* @global WP_Query $wp_query Global WP_Query instance.
*
* @return bool
*/
function is_archive() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $wp_query->is_archive();
}
示例:
相关函数:
is_tag()
is_single()
is_home()
感觉本站内容不错,读后有收获?小额赞助
还可以分享文章给好友:
学习了。来访
欢迎常来!!!