Just add a counter to the loop.
Just use $wp_query->current_post
while ( have_posts() ) : the_post();
if($wp_query->current_post <= 1) // 1 because counter starts at 0
// <div>first 2 posts go here</div>
if($wp_query->current_post > 1 <= 3)
// <div>second 2 posts go here</div>
if($wp_query->current_post > 3 <= 5)
// <div>last 2 posts go here</div>
endwhile;
Related Posts:
- query posts in wordpress
- posts_nav_link(); not showing up on static pages
- Get list of months with posts
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- Custom URL parameters in template files
- Metadata Query when storing data as array possible?
- Keep sticky posts out of query unless they have featured image
- How to query the latest 5 posts and sort them by title?
- 2 loops, is_home won’t work, count is off
- 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?
- 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
- WP_Query not getting all posts, just tagged posts
- tag__in does not return posts
- View list of all attachments on site
- Best practice for implementing a blog page / section in wp_menu_nav()
- Not the typical order by posts by date question
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- issue displaying variations in custom template using WPeC 3.8.9.2
- When to use add_action(‘init’) vs add_action(‘wp_enqueue_scripts’)
- Change admin bar to default:off
- How to add Color Picker in Theme Options for the following?
- Template for individual post designs
- How to know if get_posts() failed?
- Theme Review: post thumbnail, header image, content width
- How to determine if a category is empty?
- The seventh parameter passed to add_submenu_page()
- What would happen if the admin installs a plugin when the plugin is included in the theme?
- How do I get my child-theme to work with my theme’s includes folder?
- wp_insert_post breaks rewrite rules
- Where can I find a good reviewed collection of Twenty Ten child themes?
- how to create theme based widget that can be drop in sider bar or footer
- CSS in child theme not overriding the parent theme [closed]
- Template Hierarchy for get_header()
- Remove frameborder attribute from iframes
- how do I get a sidebar’s id or number for use with is_active_sidebar()
- Looking for the code in twentyten that allows users to select images for the header/banner
- WordPress as a data intensive web app
- How to determine which custom header image is being shown
- using wordpress without javascript
- Theme Check: Could not find post_class
- Override theme programmatically
- How do I remove TinyMCE text format
- can’t understand _e function well
- WP 3.1 upgrade breaks AutoFocus+ theme
- Comment entry screen shows even though “Allow Comments” is unchecked
- Custom WordPress Theme – Search not working on posts
- Change content layout based on menu hierarchy
- Theme Loading Into Dashboard
- How to make theme elements customizable in wordpress?
- Where to hook settings api init
- Change “Thumbnail”, “Medium” and “Large” image sizes using functions.php?
- How to obtain a reference to the_excerpt() from custom loop
- defining a folder location in order to recall it
- JavaScript stops working on selectively refreshed sections one inside the other
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Why doesn’t my css work when I check my theme on mobile devices? [closed]
- Common single page template options
- Custom Blocks as part of a theme
- How to set up diffrent mobile theme for single site in WordPress?
- Enqueued JavaScript is not working
- Show specific category posts on Genesis framework home page
- How to fix : Uncaught ArgumentCountError: Too few arguments to function? [closed]
- I have WordPress setup on primary domain, how do I set it up on its subdomain using the same database?
- Theme development – Automatically menu creation
- Questions from a new WP Dev [closed]
- How to enable Disqus comments in a WordPress theme I’m creating from scratch? [closed]
- tiny_mce_before_init: ‘exact’ => true has no effect
- pre_get_comments or the_content filter
- Pagination not working on custom post page
- What might cause a featured image not to display?
- How to conditionally add a wp_filter
- How to set default values for edit_post_link() in my theme?
- Stop WordPress from showing images on non post pages
- enqueuing external and internal js and css in wordpress did not work with owl.js animate.css
- Wrong activation/confirmation link in email
- Disabling wordpress added class
- Problem with pagination link (error 404)
- WordPress wp_get_current_user returning blank values until refresh
- use a single nonce in three different nonce field
- Whether an tag is required in header?
- Theme is Enqueueing Everything in Footer
- Local theme changes upload on server but theme changes not showing
- wp_kses allow checkbox class and checked
- Understanding WordPress theme files and underscores
- New theme HTML5 Support for Search in WordPress 4.4
- How do I remove p tag *insertions*? Disabling `wpautop` removes manual tags
- What hook to use for loading a custom class extension during Theme initialization?
- What are these variables and where are they documented?
- Use external fonts in WordPress stylesheet
- Custom link color or stylesheets
- What is the advantage of using home.php over index.php for the front page
- Why do some sites show themes/”themename” as the only theme?
- How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
- Bootstrap 4 mobile menu not working for WordPress Development
- How to make it so I can “use” template parts in (classic/full) site editor
- How do I send out an update for my custom wordpress theme?