block_core_navigation_get_most_recently_published_navigation

函数


block_core_navigation_get_most_recently_published_navigation ( No parameters )
返回值
  • (WP_Post|null) the first non-empty Navigation or null.
定义位置
  • wp-includes/blocks/navigation.php
    , line 257
引入
弃用

Finds the most recently published `wp_navigation` Post.

function block_core_navigation_get_most_recently_published_navigation() {
	// We default to the most recently created menu.
	$parsed_args = array(
		'post_type'      => 'wp_navigation',
		'no_found_rows'  => true,
		'order'          => 'DESC',
		'orderby'        => 'date',
		'post_status'    => 'publish',
		'posts_per_page' => 1, // get only the most recent.
	);

	$navigation_post = new WP_Query( $parsed_args );
	if ( count( $navigation_post->posts ) > 0 ) {
		return $navigation_post->posts[0];
	}

	return null;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。