WP_Query::__construct() WordPress Method

The WP_Query::__construct() method allows developers to query the WordPress database and return results from specific posts or pages. This method can be used to create custom loops or to modify existing ones.

WP_Query::__construct( string|array $query = '' ) #

Constructor.


Description

Sets up the WordPress query, if parameter is not empty.

Top ↑

See also


Top ↑

Parameters

$query

(string|array)(Optional)URL query string or array of vars.

Default value: ''


Top ↑

Source

File: wp-includes/class-wp-query.php

	public function __construct( $query = '' ) {
		if ( ! empty( $query ) ) {
			$this->query( $query );
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
1.5.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