You’ve given WP_Query
and empty argument set, effectively asking it to get “nothing”. Try:
$args = array ();
$query = new WP_Query( $args );
var_dump($query);
As soon as you give it something to latch onto, like your tag argument, the query works. To get all of your posts pass a post_type
argument.
$args = array ('post_type'=>'post');
$query = new wp_query( $args );
var_dump($query);
Or to get all post types…
$args = array ('post_type'=>'any');
$query = new wp_query( $args );
var_dump($query);
Or to only get particular post types…
$args = array ('post_type'=> array('post','book'));
$query = new wp_query( $args );
var_dump($query);
Related Posts:
- query posts in wordpress
- posts_nav_link(); not showing up on static pages
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- How can I prevent posts with no title showing up in my query?
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- issue displaying variations in custom template using WPeC 3.8.9.2
- Get ‘page’ number with infinite scroll
- Get 10 posts from a WP_Query. If less than 10, get the remainder from elsewhere
- Why doesn’t /2013/01/ properly return January’s archives in archive.php?
- Strategy to get post meta for use outside the loop
- Grab the first paragraph of each post
- Single Page WordPress Theme – Using page templates
- A two column loop with one lead post
- Change loop order via form or link (jquery, not URL)
- First post of each category
- Is there any need to use both wp_reset_postdata and wp_reset_query together?
- Getting Permalink within the loop
- the_content() in single-{post-type}.php problem
- Why does this loop only work on the homepage?
- Why is this coming back as null? Thats wrong. There is one post
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- Get list of months with posts
- Finding Page Template and Displaying Content
- How WordPress converts URL to $query_string
- Link won’t show using the_permalink();
- Force index.php have_posts() loop to exit if no sticky posts found
- Custom URL parameters in template files
- Metadata Query when storing data as array possible?
- show a post from a specific post format
- Displaying recent post excerpts on static front page
- Keep sticky posts out of query unless they have featured image
- How to show user online status on their posts?
- Custom get_the_excerpt() only works on first post
- Two loops on archive page
- Check if loop has any categories?
- Echo all category names, apart from one
- how to get the post attachement image in full size?
- How to query the latest 5 posts and sort them by title?
- Get the amount of posts on a given page
- 2 loops, is_home won’t work, count is off
- How to list articles by year based on url?
- Wp_query with 2 meta keys and array of meta values
- Custom WP_Query doesn’t display all posts
- Change image size depending on page
- WP_Query with custom post type ID
- CSS class on last post in loop ( custom query )
- Custom Post Type Query issue
- How to order by multiple date meta_values?
- How to create query to get top 3 sticky/latest posts
- Previous and Next links not populating, have I missed something?
- Get all posts as an array ID => Name
- Twenty Seventeen Pages Loop
- How does the loop know which post to view?
- how to handle the loop using filling bootstrap grid structure?
- Writing less unnecessary code with WordPress
- Retrieve WordPress’ the_content() with jQuery
- Exclude subcategory from wp_query
- Style first 3 posts differently with WP_Query [duplicate]
- tag__in does not return posts
- View list of all attachments on site
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- Pagination and multiple loops
- multiple queries to get posts from same category?
- Search.php gets metadata from first post
- Best practice for implementing a blog page / section in wp_menu_nav()
- How can I sort my loop based on meta data, using a form?
- List categories of a post hierarchically?
- Exclude parent categories from the_category() within the loop
- get_the_terms() returning wrong results inside of loop
- Show only pages you are author of
- How do I make my terms for each product display via foreach loop? (woocommerce)
- WordPress Insert ads after every 5th post
- White screen of death on index.php page 3 and above?
- WordPress theme files Organization
- Infinite loop when nesting have_posts()
- Local variable name in setup_postdata()
- Loop is breaking my theme. How can I fix?
- my ajax wont sent the data, please correct my code
- control posts order by select option
- Problem with Displaying Custom Theme Page’s Content
- active link for most recent post on vertical tabs
- How to show the posts list into a static page? Problems to use the loop into a static page
- Conditional loop based on current page
- Suppress the_content filter in a nested loop
- Tags interfering with next_post_link();
- Simple loop with shortcode rendering problem
- How get the 10 most viewed pages (not post)
- The normal loop with different styles doesn’t work in search.php
- Checking conditionals
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- All post ids are the same after this query but rewind_posts() does not seem to work here?
- Not Found when using activity stream as front page with BuddyPress
- Why does the first loop take arguments from the second loop?
- have_posts() return false on single post
- How to defeat “Blog pages show at most __ posts” setting in the loop?
- Display Page featured Image as well as Posts featured Image
- Get author meta data with no published posts in author.php?
- WordPress Loop with Custom Post Type for Bootstrap Accordion [closed]
- Is there any reason that other theme elements (such as nav menus) shouldn’t be within the loop?
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?