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
- How WP determines archive page vs single page?
- How to prevent random 302 canonical-ish redirect on custom template
- How to apply pre_get_posts to a custom query?
- WP_QUERY tax_query not working
- Pull comments from one page/post into another page/post?
- How to get latest post excerpt from a specific category?
- Which is from this queries is more faster
- Start Query from 2nd Post without offset
- Get all content on a “single page” site depending on language
- Get list of all Grandchild Pages
- Execute PHP function inside the admin area
- get latest added term from taxonomy and insert into php variable
- meta_query returning excluded result
- WP_Query: attachment image in “full” size?
- Featured images loop for Orbit Slider
- Filter subpages in while loop from WP Query object
- Attempt to display site authors in a carousel – User Image not Outputting inside li tags
- Adding pagination to sub-wp_query within a singular post page
- How go give $value to wp_query
- templates with page teasers Or Featured Items
- Show multiple tax_query from 2 or more post_type in a single code
- wp list pages using meta box value
- Add AJAX “Load more” on custom query block
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- get_var is neither a string, integer, or array …?
- Posts limit on homepage (genesis framework)
- How to filter a static post page with ajax and $wp_query
- Query not sorting DESC
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- how to translate countries output from wp database?
- WP_Query with 2 genres
- wpquery via ajax
- Custom query does not find pages
- Deleting terms from the WordPress wp terms table
- Display posts from an array of ID’s
- Pagination problem by using WP_Query
- Date not appearing in custom query