WP_Customize_Manager::has_published_pages(): bool

In this article

Returns whether there are published pages.

Description

Used as active callback for static front page section and controls.

Return

bool Whether there are published (or to be published) pages.

Source

public function has_published_pages() {

	$setting = $this->get_setting( 'nav_menus_created_posts' );
	if ( $setting ) {
		foreach ( $setting->value() as $post_id ) {
			if ( 'page' === get_post_type( $post_id ) ) {
				return true;
			}
		}
	}

	return 0 !== count(
		get_pages(
			array(
				'number'       => 1,
				'hierarchical' => 0,
			)
		)
	);
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

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