You can simply do it by wrapping closing divs in if condition where current_post is equal to 2. I have added it in following code
<?php if ($query ->current_post == 0) { ?>
<div> Post # 1</div>
<?php } ?>
<?php if ($query ->current_post == 2) { ?>
<div class="extra">
<div class ="extra2>
<?php } ?>
<?php if ($query ->current_post >= 2) { ?>
<div> Post # 3</div>
<div> Post # 4</div>
<div> Post # 5</div>
<?php } ?>
<?php if ($query ->current_post == 2) { ?>
</div>
</div>
<?php } ?>
<?php if ($query ->current_post == 1) { ?>
<div> Post # 2</div>
<?php } ?>
Related Posts:
- Grab the first paragraph of each post
- Single Page WordPress Theme – Using page templates
- First post of each category
- Finding Page Template and Displaying Content
- Some doubts about how to show posts in a custom theme?
- Echo all category names, apart from one
- how to get the post attachement image in full size?
- Change image size depending on page
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- List categories of a post hierarchically?
- Local variable name in setup_postdata()
- How get the 10 most viewed pages (not post)
- Why am I getting posts back when I shouldnt
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- Add a dropdown to theme customizer
- What is the problem if I use CDN in my WordPress parent theme(built using bootstrap)?
- Is it possible to use line break in theme description?
- How can I get wp_head() as a string instead of echoing it?
- How to check if post has any tag?
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Example of a theme organization without all the default wp files in root
- Which is the simplest theme for WordPress to use it as your base?
- “Cheatin’ uh?” error message on multple theme directories
- Adding WordPress colorpicker in widget settings
- Disable the Custom Internal CSS added by theme.json for Certain Pages
- A theme that follows all the best practices to learn from?
- get_post() function returns post even if it is trashed
- How to highlight the current page in the nav menu?
- “Display Site Title and Tagline” checkbox not working?
- Add social icons in a theme through custom admin menu
- file_get_contents Not allowed in Themes?
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- Custom Nav Walker Displaying Values in Sub Menu
- 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 do I remove twentyten without ruining what I did?
- Custom theme not visible in Appearance
- Developing WordPress Theme using CSS framework like Bootstrap
- WP_Customize_Color_Control omitting # symbol
- Theme translation not applying
- How to add filter the post thumbnail before save in database?
- Can I have two different theme for two different language?
- Storefront child theme not applying parent theme [closed]
- WP_Comment_Query – Get comments and answers separately
- excerpt() shows different result between remote and localhost(development environment)
- Theme Inspector “X-Ray”
- Acivate all themes multisite wide automatically
- How to place HTML tags in content from the_content()?
- WordPress Theme Creation [closed]
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- Integrate WooCommerce theme with a WordPress theme [closed]
- Automated Footer information
- How do you use WordPress for a website that’s not in a blog format?
- Managing WordPress Theme
- How to track a users last visited page?
- In a Gallery with limited image posts, how do I not limit images on single post?
- LESS not working in WordPress [closed]
- How to add custom page elements to the WYSIWYG editor?
- Why I obtain different visualization when I run the website on my local machine and on remote server?
- How to use the _S framework
- Open portfolio image in light box
- Let visitors show/hide a type of content
- Best practice for implementing a blog page / section in wp_menu_nav()
- how to add a badge on product based on filter?
- Show only pages you are author of
- how to create/register menu items that can be added to menus later
- Why nav_menu_css_class doesn’t work with apply_filters?
- White screen of death on index.php page 3 and above?
- WordPress and Semantic UI
- Customizer API Multi Sections in single Panel
- WordPress theme files Organization
- Theme does not allow shortcodes
- Text widget is placing everything side by side. I want to post it above
- What is an alternative to not using child theme to customize a WordPress theme?
- my ajax wont sent the data, please correct my code
- Menu names not getting translated
- How to generate a rtl.css file for themes?
- Get property of non-object on theme activation
- change wordpress website logo url [duplicate]
- wp_editor some functionality not working on custom theme
- Update modified Shopify third-party theme [closed]
- hide/show a div in wordpress
- Providing updates to your WordPress theme
- One-Page WordPress Template
- Weird ‘theme update’ error [duplicate]
- How one category can have different fields?
- How do child themes work?
- Fail to install theme on development copy of WordPress on Webmatrix
- How to prevent XSS attack in wordpress theme?
- Featured Image Module Randomly Disappears
- Tags interfering with next_post_link();
- adding navigation to genesis themes
- Standard Way To Do Custom Work Within A Page?
- Confused on loading page content
- Add Dynamic Sidebar to Exisiting WordPress Theme [closed]
- Why does the first loop take arguments from the second loop?
- How can I install my custom-made theme on a wordpress.com blog? [closed]
- 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?
- .submenu class missing in output from wp_nav_menu