Initiating new WP_Query($post)
shows all posts. Credit to @Latheesh V M Villa
Add:
$loop_query = new WP_Query($post)
Then change loop values like:
have_posts()
to:
$loop_query->have_posts()
loop.php
<?php $loop_query = new WP_Query($post); if ($loop_query->have_posts()): while ($loop_query->have_posts()) : $loop_query->the_post(); ?>
<article class="loop-template" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- article content here -->
</article>
<?php endwhile; ?>
<?php else: ?>
<article>
<!-- else content here -->
</article>
<?php endif; ?>
It appears you can leave everything inside the loop alone such as the_ID()
and the_title()
.
Great article at smashingmagazine here
Related Posts:
- Post X of Y in single.php / sidebar.php
- How to have different content in the loop and single
- Display all posts that were published before full post on single.php
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- Do we still need to include a “if (have_posts())” in templates?
- Query *only* sticky posts
- Using single.php from plugin folder instead of default template folder
- Related Posts by Multiple Tags?
- Cannot access current post’s ID in custom plugin
- Can’t show comments count per post outside loop
- Show a list of recently viewed posts to a user
- Alternate custom content in the loop
- Auto Refresh Post List after X seconds
- How to show video from specific category on sidebar?
- how load content as pop-up using ajax
- Display posts with comments closed, with pagination?
- Related posts loop based on tags AND categories doesn’t work without at least one tag assigned
- Can’t get the_content of the parent page from its single post?
- Get latest posts from WordPress site without header, menu and sidebar
- Display post category in foreach loop with category link
- How To Get Posts With A Specific Word
- How to display posts on a static page? (like search loop)
- How to show single post page as home page
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Displaying Latest Posts on a Page
- How can I make a post that belongs to a category or have specific tags, display different from the other single posts?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- problems with loading posts in a table-row
- Blog page pagination is not working after using the offset argument
- WP Query – Posts Per Page not working in combination with category__in
- More then one menu items are assigned with “current-menu-item” class
- Add Read More Tag to a post content (Single.php)
- How to add tags (custom taxonomy) to post class css?
- List authors with the last post title and order by last post date
- Listing Specific Categories from Current Post with Depth
- Only display sticky post or latest post in custom loop
- get_the_category listing in hierarchial order
- How to make a sum of all posts displayed in a loop
- Exclude current custom post on single post
- 2 dynamic sidebars registered, not showing up
- Thumbnail Image to go in the post aswell
- First x post with another template then the others
- Sidebar show posts by current category also in single post
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- Loop parent terms {display posts} AND loop child terms {display posts}
- add bootstrap post slider with tabs
- Custom taxonomy archive page problem
- Loop don’t work within single.php page
- Add Blog to WP homepage Manually
- Getting blog pagination to work on page set as front page
- Make loop inside slider divisible [closed]
- Defined function isn’t showed on page
- separate the post of a category by subcategory
- How to display post list in a table layout (multiple queries in single loop)
- Not all posts showing in query
- Limiting the amount of posts retrieved by the loop
- Display 3 posts with different HTML markup using a loop
- How to repeat a loop after 4 posts [duplicate]
- How to separate each individual blog post?
- Is there a way to define the $post var outside the loop?
- Only the most recent post is showing on my category page (working on localhost, not live site)
- WP posts using index.php instead of single.php
- Single post shows post three times
- How do I check if a post is password protected?
- Can I Paginate Post after every 25 tag?
- Alternative content between posts no repetition
- Start loop from specific post ID
- Display new posts categories in separated divs
- Wp_query loop is not working as it should
- Maximum number of posts per page before affecting performance?
- Display post order ranking within wordpress loop
- Problem with wp_insert_post()
- How to control Post view count incresing in sidebar widget posts too?
- Get the category of post
- WordPress loop uses unmodified posts array, why?
- Add row after three columns
- Custom Single Post Type not referring to single-post-type.php File
- Modify WordPress loop after it has been run
- Skip posts, but keep posts per page
- Multiple Post Repeat for Related Post Loop by Category
- Correcting the content width when sidebar is inactive?
- index.php is only displaying current month’s posts?
- Thumbnail With Next/Prev Links Not Showing Next Post?
- Loop doesn’t display posts. It displays a link to the home page instead
- Grab next post title in archive page
- Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
- Getting posts from multiple users?
- Pagination and Related Posts
- Loop through posts by each term and exclude duplicate posts assigned to several terms
- Show post if in category
- Displaying categories items among posts
- Single post page from static home not working
- Get current post’s child page?
- How do I display the next 3 posts in the sidebar?
- Only show posts with image and the correct ammount of posts in loop
- Show all posts in category
- First post in loop displays twice
- Wrap every 2 posts
- What function does the loop of displaying posts?
- What template file is used by default for posts?