You can check if the query returned any posts by doing $home_query->have_posts()
.
$home_query = new WP_Query( array('posts_per_page' => get_query_var('posts_per_page'),'paged' => $current_page ) );
if( !$home_query->have_posts() ){
// Do this if $home_query had no posts.
}
Related Posts:
- Hiding posts in a list from specified categories
- Query function not executed between element [closed]
- Function to execute when a post is moved to trash .
- Get current post id in functions.php
- How to publish a post with empty title and empty content?
- How to exclude latest x posts from a paginated query?
- Query posts distinct authors
- How to get previous 10 days post from a specific date – WP Query
- How to Display Post View Count
- Function to show random posts from a category
- How would I get 1 latest post from a query for 5 posts?
- Exclude posts with empty post_content in wp_query
- Create cron job without a plugin?
- Improving WP_Query for performance when random posts are ordered
- Reset Popular post query?
- Why WP_Query(‘showposts=5’) shows only 1 post?
- is there a way to show the the post title after the image?
- Blog post per page setting conflicting with custom WP_Query?
- Change post order random through out the entire WordPress
- How to exclude latest x posts from a paginated query?
- How to do set post permalinks using 6 digit random unique function?
- Random ajax load only works with posts_per_page set to -1
- posts_per_page option limits the number of Gallery items
- wp_posts table: safely remove unused columns to save database storage
- Query Posts by Custom Field
- Order posts alphabetically: how to set order=asc in mysql query?
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- Every second post different class in blog view
- why the same code got different results when using query_posts in functions.php and index.php
- Query for first 3 posts to change the look and feel
- How to get posts published on the latest date?
- How to only publish posts with image in it
- Shortcode with ‘year’ parameter
- On what hook can I get the queried object’s final state?
- wp_query with ajax
- How to give classname to post if post has no content?
- WP_Query: Show 10 posts in date order, first three random
- Get post by tag
- Random posts that always include a particular post?
- Related Posts function not working
- WordPress post filter menu
- Echo the number of posts being displayed
- WordPress query portfolio posts
- Same post appears in related Posts?
- Display 3 posts with different HTML markup using a loop
- Change content off every sixth element
- how to show comments only author which send own posts in wordpress
- Show posts from two specific category in WP_Query
- How to create loop of posts except post ID defined via ACF field
- Displaying all posts from other sites on the network on one site
- the wp_post_update isn’t working all the time
- Function is printing twice – any suggestions?
- Multisite how to display merged posts from two sites and sort by latest date?
- Show 5 posts and than 3 posts offset with pagination
- wp_query args with relation
- Manipulate query to show specific post
- Show all posts from the tags without having to set all of them
- How to correctly escape data
- Sort / Filter Queries
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- How do I control the fallback query after the original query returned cero posts?
- Remove duplicated posts in the loop if post has more than one category
- Adding a category at even positions on main loop with modified pagination
- How to limit the number of results for all query_posts on mysite
- wp_query select if have comments
- wp trim function not working
- How to modify this function to exclude also the post belonging to a specific category?
- query_posts different amount of posts per page [duplicate]
- Filters do not work when there are multiple (one works)
- Accessing the post content with WP_Query
- List only child categories a post is in, of a specific parent category
- How to change post status from publish to draft using hook in wordpress?
- How to output comments number of a post per day?
- Display posts with comments closed, with pagination?
- I want to query posts in monthly basis
- Why is querying posts messing up my pages?
- Multi row post list
- Get posts with multiple categories
- Do not show children of a category
- Update post meta within save_post action
- Not all posts showing in query
- Related Posts: Changing Function For Posts Per Page
- get parent fields title, content excerpt etc
- How to show multiple posts thumbnail, title and date in widget
- Group first, 2nd, 3rd, etc posts by category terms
- Manipulated offset and pagination, can’t display last post anymore
- Is there a way to know when a page has been updated and do some action only once?
- posts_per_page displays only 2 posts instead of 4 posts
- How to display particular set of wordpress post on a webpage?
- I want to change the WordPress comments file
- subtracting the current post form then whole loop, which is generating all CPT titles
- Excluding tag Link from html tags in Post content
- Changing a users posts to drafts upon role change
- Trim excerpt to first paragraph
- WordPress loop uses unmodified posts array, why?
- how to repeat taxonomy in different places on wordpress
- Show posts between two Custom Fields date
- First post in loop displays twice