WordPress函数:is_month 确定查询是否针对现有月份存档

江河/ 2023年09月05日/ WordPress/ 浏览 487

函数原型:


is_month(): bool


确定查询是否针对现有月份存档。


有关此主题函数和类似主题函数的更多信息,请参阅主题开发人员手册中的条件标记文章。


函数源码:


function is_month() {
	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_month();
}


使用举例:


if ( is_month() ) {
	// Do awesome.
}


发表评论

暂无评论,抢个沙发...

客服 工单