WP_Customize_Manager::has_published_pages() WordPress Method

The WP_Customize_Manager::has_published_pages() method is used to check if there are any published pages on the current site. This is useful for determining if a static front page is available.

WP_Customize_Manager::has_published_pages() #

Returns whether there are published pages.


Description

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


Top ↑

Return

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


Top ↑

Source

File: wp-includes/class-wp-customize-manager.php

	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 ) ) );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More