You can keep tracks of number of cycles and run extras when counter matches. Something like this:
$array = array(1,2,3,4,5);
$i = 0;
foreach($array as $set) {
if(2 == $i)
echo 'after 2';
if(4 == $i)
echo 'after 4';
echo $set;
$i++;
}
I must note that this is more of PHP basics and really has nothing to do with WordPress. I highly recommend PHP documentation as first stop for such.
Related Posts:
- WordPress Paginate $wpdb->get_results
- Custom Search Query
- Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123
- Retrieve and display data from custom db table in admin area?
- How to find if a post with custom_field == X exists?
- Custom search page and search by title, content and tag
- Modifying loop on a custom page, strange behaviour
- How I display post of the post type group by year of post?
- Load more posts with multiple queries
- Hi, I wanted to make custom search with multiple fields
- $wpdb->replace: WHERE?
- wp_query get post custom taxonomy in search.php
- Order posts with a custom field but also without
- Save title as custom field on custom post type
- Custom Loop Query For Search Page
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- Query for specific custom field
- Display posts by combining multiple meta key
- Custom select query two tables by a meta key
- Custom Same Page Search
- Fatal error Call to a member function insert() on a non-object [closed]
- custom user meta query
- Recent activity query WordPress
- How to query term_id of a Custom Taxonomy by name
- WP Search Form Query: Add Author’s posts into search query
- query variables for custom taxonomies
- display text generated via custom get query string
- Custom query pagination with php parameter as arg problem
- How to automatically pull an information from a form field onto an other page?
- Query Posts to display all posts with category “custom field value”
- Query 1 custom post type, each day, alphabetically
- Multiple Taxonomies Using Custom SQL Query
- Search a meta field for a value in all posts
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Custom MySQL query to list post
- Custom Query Arguments
- Custom Query for Taxonomy
- Include plugin´s table in custom query
- User Query Multiple Orderby Clause
- Customizing gallery shortcode in 3.5
- Can You Export Theme Settings From WordPress Multisite?
- Adding Custom Fields to WordPress Comment Forms?
- Any Hook Called When Post Becomes Published?
- Automatically wrap post image in div
- How Can A Widget With Only One Instance Be Defined?
- Getting $comments outside the comment template
- Find and replace domain name on the fly?
- WordPress Template not affecting the working, keeps defaulting to the index.php template
- Custom Widget form function common elements
- WP Northwind for Theme Development?
- list/consult Taxonomy only for the respective author/creator in dashbboard
- How to insert a sitemap within a subsite when using WordPress multisite
- Enabling Additional CSS / custom-css
- Child Theme – how to add new widget on a specific place?
- Modify Gallery Output to render differently on a PAGE and a POST
- @font-face is not working in WordPress
- Add google org chart to wordpress page
- I’m using add_meta_box() but want to include TinyMCE editor *and* Media Uploads for each box
- How-To add Custom field in WordPress wp-ecommerce Categories?
- What changes we need to make to a theme so it can be installed as a MU Theme?
- Get Custom Logo Alt Text
- The function can not create a table on MariaDB server
- Child theme .css files are not overriding their parent .css files
- One WordPress Installation for 2 Domains
- result from custom filter admin table list backend does not work
- Blog page problems
- Installing new theme on running site
- Best way to allow overwriting images shipped with the plugin?
- Static Front Page settings – distinguish between Front page and Post page
- How to format text of site subtitle
- Undefined variable: user_id in get_user_meta
- Customizer JS API get value of customizer field
- WordPress broken after domain name change
- Daylight Saving Time adjustment
- How to Restore Deleted Post Not in Trash
- Hide content and functions from specific user roles
- Translating (WooCommerce) placeholder text
- Display content of metabox if filled in
- User profile Pick a premade Design/theme
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Can we set a redirection with dynamic content in url?
- How to remove (…) from the post tilte on homepage?
- Swap home page based on user role, Elementor layout breaking
- Customized Blog/Latest Posts Page
- How can I setup a development environment which auto refresh page when code have changed [closed]
- Password Protection issue
- Change Dashboard menu position?
- Get site ID from attachment url?
- how to edit or remove the dashboard footer message [duplicate]
- duplicate featured image functionality in custom meta box
- How to create a custom menu for specific user
- How to work around the bug which prevents custom menus from being deleted?
- How to remove the tagline from the HTML ?
- Custom table or form
- How I can add blog in my magento site?
- Adding Telescope / Meteor App to existing WordPress site
- Disable all Fonts that are Standard in WordPress and replacing them with a custom Font?
- Custom product sorting archive page
- Add custom information in editor summary
- A Voting system for a pageants