block_core_calendar_has_published_posts

函数
block_core_calendar_has_published_posts ( No parameters )

block_core_calendar_has_published_posts: 这个函数用来确定在一个给定的日期是否有任何已发表的文章。它接收一个日期字符串并返回一个布尔值。

返回是否有任何已发表的文章。

当没有发表的文章时,用于隐藏日历块。这弥补了一个已知的核心错误:https://core.trac.wordpress.org/ticket/12016

function block_core_calendar_has_published_posts() {
	// Multisite already has an option that stores the count of the published posts.
	// Let's use that for multisites.
	if ( is_multisite() ) {
		return 0 < (int) get_option( 'post_count' );
	}

	// On single sites we try our own cached option first.
	$has_published_posts = get_option( 'wp_calendar_block_has_published_posts', null );
	if ( null !== $has_published_posts ) {
		return (bool) $has_published_posts;
	}

	// No cache hit, let's update the cache and return the cached value.
	return block_core_calendar_update_has_published_posts();
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 19:32:59

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: