WordPress queries are indeed represented by WP_Query
objects. The snippet example you have is secondary query, as opposed to main query – which is run by WP itself during core load and stored in global $wp_query
variable.
Typically it is better (for performance and compatibility) to modify main query for set of posts that is main to page – see pre_get_posts
hook documentation.
When you are running query loop, what happens is that WP fills number of global variables (main being $post
) with data for current post. Functions that access those variables and output information (such as the_title()
) are called template Tags
and Codex has list of them that should get you started.
Related Posts:
- add_filter(‘query_vars’) not working in custom template
- How to generate feed for custom template
- Passing query variables to a custom page template
- Adding css tweak based on page template
- Page template query with WP_Query
- How to display page content in a page template?
- How to prevent execution of default query, while preserving ability to use WP_Query in template?
- How to stop wordpress to make the default query?
- $wp_query initiation?
- Executing Queries in tag.php
- Which custom query am I in and how can I access its properties & methods?
- Single page theme that uses pages for the content
- Trying to list out child pages with WP_Query
- Front End Sorting Questions
- Pass the same object to multiple widgets in a template with one query
- What are the differences between “Latest Posts” and “Static Page”?
- Help with CPT template pagination
- WP_Query doesn’t get sticky post at the top, when used in a page template
- Have functions work outside the loop with 404 override
- Pagination of a WP_Query Loop in a child-page page template
- list pages using page.php and NOT page-{slug}.php
- Show all post for a given category
- Get pagination working for custom loops within page templates
- How is WP_Query parsed to determine which template to request?
- WordPress Pagination changes my template
- Is there a better way to pull in custom content without querying posts?
- Pass $page_id to new WP_Query
- WordPress Custom Search Form Displaying Unexpected Results
- Is there a way to make this kind of loop shorter and nicer?
- Pagination on template page for custom query redirecting to index.php
- Utilising an existing page while using the “s” query parameter
- Create a page template for “top rated posts” but show full content and not just a list
- WP_Query returns different results from get_posts() [closed]
- inserting content of 1 Post to in another with a template hierarchy
- Get posts in taxonomy randomly
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- wp_query on page template not working (Genesis framework)
- Pagination for custom loop on custom page template is not displaying anything
- How to create Page templates for showing Blog posts in different layouts?
- Unable to paginate a custom page query
- How to stack name list in non-alphabetical order?
- odd behaviours from template tags
- Page template doesn’t display simple HTML if inserted into other page?
- problem with the loop
- get_children() Archive Template
- In a WP_Query can I force the results’ is_singular() to be set to false?
- How to separate two columns from one content on a page template?
- What’s the best way to make a blog page on WordPress?
- How to use custom page for all posts with custom url, call another directory?
- INNER JOIN custom tables – SQL Query
- How to display a post(by id) along with css in a page?
- Pagination Shows Up But Won’t Work on Custom Gallery Page
- ACF: using two loops, the_field returns field content from another loop
- How to exclude posts by ID within a category/archive loop
- Search Filter With Custom Taxonomy and Custom Fields : How do I handle it via plugin?
- How can I use a specific wordpress page template if certain words are used in page title [closed]
- Fetching $_POST from Page Template into functions.php
- Using URL variables on a custom WP_Query
- Pagination is not working on custom query inside a custom home page template
- When importing a database any page with a wp_query in doesn’t work
- Having trouble using this post category query on multiple pages?
- WordPress pagination returns the same posts
- on attachment.php, how to display previous and next attachment links that follow the same order as a custom WP Query
- order by numeric value for meta value
- numberposts? showposts? posts_per_page?
- $GLOBALS[‘wp_the_query’] vs global $wp_query
- Some doubts about how the main query and the custom query works in this custom theme?
- How to query only for products with status “in stock” in WooCommerce? [closed]
- Does WordPress sanitize arguments to WP_Query?
- How to order posts in wp_query by a meta_value of the corresponding author
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- Get the post thumbnail with wp_query
- Where to use $post global variable?
- Refine/Filter WP_Query Posts with jQuery or Ajax
- Storing query variable and then using wp_reset_query
- exclude posts with a specific custom field and value
- Redirect page when URL parameter not set
- Moving the array pointer inside a WP_Query while loop
- Help with WP_Query – Too many mySQL queries
- Get a list of posts with associated meta_value
- Does wordpress templates always in files or in database?
- Query post with meta value in set of values
- get_template_part causes 500 error
- Max Posts and Memory Limit
- Using Ajax and WP_Query to load more posts on category page fails
- I have problems with the search query using multiple post types
- Different query result on local and server
- WP_Query about meta_key and its array value
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Get Current CPT taxonomy category in shortcode
- Custom Content Slider stop duplicate
- Sort Posts with custom meta key by default which is currently set as optional
- wp_query pagination links producing 404
- Using custom post types within a section of a template
- Pagination problem with multiple loops on the same page
- WP_Query – meta fields numeric
- How to query posts from single post format on Genesis framework
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2
- Prevent URL Parameter Affecting other WP Query