WP_Navigation_Fallback::get_most_recently_published_navigation(): WP_Post|null

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Finds the most recently published wp_navigation post type.

Return

WP_Post|null the first non-empty Navigation or null.

Source

private static function get_most_recently_published_navigation() {

	$parsed_args = array(
		'post_type'              => 'wp_navigation',
		'no_found_rows'          => true,
		'update_post_meta_cache' => false,
		'update_post_term_cache' => false,
		'order'                  => 'DESC',
		'orderby'                => 'date',
		'post_status'            => 'publish',
		'posts_per_page'         => 1,
	);

	$navigation_post = new WP_Query( $parsed_args );

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

	return null;
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.