On this page
WP_Query::__construct( string|array $query = '' )
Constructor.
Description
Sets up the WordPress query, if parameter is not empty.
See also
- WP_Query::parse_query(): for all available arguments.
Parameters
$querystring|array Optional-
URL query string or array of vars.
Default:
''
Source
File: wp-includes/class-wp-query.php. View all references
public function __construct( $query = '' ) {
if ( ! empty( $query ) ) {
$this->query( $query );
}
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Query::query() wp-includes/class-wp-query.php | Sets up the WordPress query by parsing query string. |
Used By
| Used By | Description |
|---|---|
| _wp_build_title_and_description_for_single_post_type_block_template() wp-includes/block-template-utils.php | Builds the title and description of a post-specific template based on the underlying referenced post. |
| wp_get_latest_revision_id_and_total_count() wp-includes/revision.php | Returns the latest revision ID and count of revisions for a post. |
| WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles() wp-includes/class-wp-theme-json-resolver.php | Returns the custom post type that contains the user’s origin config for the active theme or a void array if none are found. |
| wp_filter_wp_template_unique_post_slug() wp-includes/theme-templates.php | Generates a unique slug for templates. |
| get_block_templates() wp-includes/block-template-utils.php | Retrieves a list of unified template objects based on a query. |
| get_block_template() wp-includes/block-template-utils.php | Retrieves a single unified template object using its id. |
| WP_Sitemaps_Posts::get_url_list() wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php | Gets a URL list for a post type sitemap. |
| WP_Sitemaps_Posts::get_max_num_pages() wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php | Gets the max number of pages available for the object type. |
| WP_REST_Post_Search_Handler::search_items() wp-includes/rest-api/search/class-wp-rest-post-search-handler.php | Searches the object type content for a given search request. |
| wp_create_user_request() wp-includes/user.php | Creates and logs a user request to perform a specific action. |
| wp_media_personal_data_exporter() wp-includes/media.php | Finds and exports attachments associated with an email address. |
| WP_Privacy_Requests_Table::prepare_items() wp-admin/includes/class-wp-privacy-requests-table.php | Prepare items to output. |
| _wp_personal_data_cleanup_requests() wp-admin/includes/privacy-tools.php | Cleans up failed and expired requests before displaying the list table. |
| WP_Embed::find_oembed_post_id() wp-includes/class-wp-embed.php | Finds the oEmbed cache post ID for a given cache key. |
| WP_Customize_Manager::import_theme_starter_content() wp-includes/class-wp-customize-manager.php | Imports theme starter content into the customized state. |
| WP_Customize_Manager::find_changeset_post_id() wp-includes/class-wp-customize-manager.php | Finds the changeset post ID for a given changeset UUID. |
| wp_get_custom_css_post() wp-includes/theme.php | Fetches the |
| WP_REST_Revisions_Controller::get_items() wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php | Gets a collection of revisions. |
| WP_REST_Posts_Controller::get_items() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves a collection of posts. |
| WP_Customize_Nav_Menus::search_available_items_query() wp-includes/class-wp-customize-nav-menus.php | Performs post queries for available-item searching. |
| wp_dashboard_recent_posts() wp-admin/includes/dashboard.php | Generates Publishing Soon and Recently Published sections. |
| wp_ajax_query_attachments() wp-admin/includes/ajax-actions.php | Ajax handler for querying attachments. |
| _wp_ajax_menu_quick_search() wp-admin/includes/nav-menu.php | Prints the appropriate response to a menu quick search. |
| wp_nav_menu_item_post_type_meta_box() wp-admin/includes/nav-menu.php | Displays a meta box for a post type menu item. |
| query_posts() wp-includes/query.php | Sets up The Loop with query parameters. |
| WP_Widget_Recent_Posts::widget() wp-includes/widgets/class-wp-widget-recent-posts.php | Outputs the content for the current Recent Posts widget instance. |
| get_page_by_title() wp-includes/post.php | Retrieves a page given its title. |
| get_posts() wp-includes/post.php | Retrieves an array of the latest posts, or posts matching the given criteria. |
| url_to_postid() wp-includes/rewrite.php | Examines a URL and try to determine the post ID it represents. |
| wp_get_associated_nav_menu_items() wp-includes/nav-menu.php | Returns the menu items associated with a particular object. |
| _WP_Editors::wp_link_query() wp-includes/class-wp-editor.php | Performs post queries for internal linking. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_query/__construct