Tried your code in a simple page and work correctly.
Have you set the “Blog” page as posts page within the “Settings > Reading”?
Because in this case the correct code that the cms will load is home.php or index.php according to the template hierarchy https://developer.wordpress.org/files/2014/10/template-hierarchy.png
Related Posts:
- How to order category.php loop by ‘meta_value’?
- How to show subcategories using loop?
- Five posts from a category in footer
- How to get all unique categories for posts in loop?
- Check if loop has any categories?
- wp_query is showing posts from other categories
- Function the_posts_pagination() not compatible with WP_Query arguments
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Get categories within specific term
- How to show specify category template for both parent and child category
- Display 3 levels of categories on page
- I have 3 categories, i want to display on a loop the last 3 of every category
- Retrieving category pages from subcategory returns empty sets
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Pagination only showed when no category is set in wp_query
- Resetting post data to previous loop in nested loops
- Pagination returns 404 after page 20
- Make loop display posts by alphabetical order
- get custom post type by tag
- WP_Query not looking at child category
- Query Custom Meta Value with Increment
- Group posts by custom field
- Transient pagination not working properly
- get_posts() seemingly ignoring post_type
- Woocommerce custom loop to show all the products [closed]
- How to show the posts of some category first, and then all other
- Pagination stops at page 6
- Paginated HTML Sitemap
- How To Remove/hide some specific categories from two different categories widget from sidebar
- Why does the_content not work like others for a set post id?
- WP_Query Order by Specific Post ID First
- How to limit total number of posts in wp query loop?
- Pagination is broken and I need help fixing it
- How to vary post loop results layout and resume?
- Show all post for a given category
- Get a post from other loop each n-posts in the main loop
- Loop returning only 1 result
- WordPress Loop and $post
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- Can we return all category (not post) with Custom Query Filter? [closed]
- Query posts intersecting tags and categories
- posts_per_page not working for first page of pagination
- WP Query with categories only shows one post and ignores the category
- Excluding pages in WP_query using ACF
- reset to main loop doesnt work
- Some doubts about how the main query and the custom query works in this custom theme?
- Exclude Category filter from Portfolio section
- Post loop for all taxonomy terms
- Stuck in the query loop
- Only display post if published in last 24 hours?
- How to remove the most recent post from $the_query
- WP_Query loop else statement not executing
- Include current post into loop
- How to display the featured image for each post?
- Check for the main query from the template
- Trying to retrieve random post, getting a page
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- has_excerpt() not working inside wp_query
- Save (and exclude) posts from loop to use in another loop on page
- Get all posts with empty meta_value
- Loop 3 posts column wise and continue the loop into same columns
- Check if a post has term inside loop
- How order posts from category by date and comment count?
- Ordering posts by custom field and grouped by month
- relation OR instead of AND – Filtered term ID’s in loop
- Compare “Main” post ID to ID inside wp_query loop
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Why does apply_filters behave different inside and outside a loop?
- Custom template for password protected page
- problem with the loop
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- Filter sub-category from checkbox form
- `offset` WP_Query argument dont work via `pre_get_posts`
- Prevent Duplicate Post Counted by Query
- 3 posts from each existing category on one page
- Pagination inside the blog page not working
- Woocommerce featured products query no longer working
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- Custom Query Pagination not working on static front page
- Multiple values in WP_Query : category__and
- query all posts published by certain user id
- Problem with custom WP_Query and underlying pagination/posts_per_page
- Only show current category post
- Pull posts from all categories if quantity is not met?
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query causing links to not work
- Iterate through ID’s in loop
- Loop through multiple custom fields with increasing number
- Different number of posts showing in development vs production server
- An archive page without post format (just standard post)
- Custom post type archive organized by category
- Pull Instagram images into an existing loop?
- Multiple loop for “featured” items returns wrong posts
- Pagination in custom query not working [duplicate]
- query_posts problem – need help
- How to write a query-function as a query-shortcode?
- First post outside of loop, homepage only?
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- How to get post taxonomy url and name in wp_query