You can try this :
foreach( $pages as $key => $post )
and :
<div class = "event <?php if( $key == ( count( $pages ) - 1 ) ) echo 'last'; ?>" >
It will add a last
class to your last event
div.
Related Posts:
- Endless loop with wp_insert_post and wp_update_post
- Add Incrementing ID to each paragraph in the_content
- post__in – Placing content from a foreach loop inside of an array
- How to iterate through database until it find a match
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- How to print out menu names in the foreach loop?
- Add class to last 3 posts in loop
- Output meta into arrays
- Need to add class to first element in a foreach loop
- Foreach displays from last to first
- Simple foreach loop help needed in wordpress “the loop”
- How to print redux gallery feilds id? [closed]
- How to check all items in a loop have post thumbnail?
- Get featured image outside the loop using foreach
- Why loop renders only last metabox from array? [closed]
- Foundation modal in wordpress php loop
- ACF field not appearing correctly in loop
- Eliminate duplicates in a foreach loop [closed]
- Wrap every 2 divs in row – for each loop [closed]
- ACF loops false value with repeater and checkbox
- Get date of last update outside of loop
- How do I get the attributes of a short code from a post?
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- How to add active class to custom menu using while loop and wp_list_pages
- “Blog pages show at most” in The Loop
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- Pagination adding extra posts only on page 2
- If Loop has odd number of posts on last page Custom style for last post in it
- Loop – how to get previous/next post for first/last post?
- Loop through all media library images and return those where caption contains the text carousel
- Must Use Plugin Causing Query Error
- Advanced Custom Fields: Post Object – Not returning data [closed]
- Custom search form to display users only
- Displaying the last page of posts
- How can I add multiple ‘tax_query’ arrays via a loop?
- How to return only one instance of each, from the entire loop
- Second level subcategory
- Combining action and filter?
- Calling & display certain product category loop and pagination on the homepage
- Detect if current page is front page within custom query
- Sanitize Custom Field Value in Meta Query
- Default ‘post’ post type archive slug?
- show random image in loop if image is not set
- Get Page content to displayin Bootstrap Modal
- need help looping add_action in wp
- Does WordPress Loop have a function like Shopify’s cycle?
- List posts that don’t have a specific tag?
- How to show more random posts if Tag has less than 3 posts
- Add leading zero to current post display [closed]
- Is there any good reason for two CSS files to @import each other?
- Is the 404 page automatically displayed if a loop returns nothing?
- Moving wordpress to different url/server creates redirect loop
- use loop to return blog details
- How to add post meta in while loop?
- Random post link generator messes up the loop
- Modify loop output for a specific list of categories
- How to Generate a list of Most Commented post?
- how can i order the category by date
- Print the whole page?
- How to add ASCII symbol after each recent post [closed]
- excerpt not showing up
- Pagination for two loops
- Search.php gets metadata from first post
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Several loops in sidebar issues
- Fetch data from two custom post types and create multidimensional array for output to html table
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- Loop only shows first two posts
- Why is my archive page looping through all but one post?
- Combine multiple separate lists into one
- Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)
- WordPress Recent Posts – Loop
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- adding tax_query to $query_string
- Get Sticky User in user loop based on user role
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- Modify category archive page loop on functions.php
- WP_Post is not from correct array
- Post formating on Home page
- divide custom field values in div every two values
- Remove posts_orderby filter then add it back in
- WP update_post_meta link loop
- Need some help with “the_widget()” function
- Conditional Check in The Loop’s Parameters
- How does the JSON API work to parse incoming JSON and fetch a post based on an ID?
- Custom single.php files for different post formats
- Exclude Authors based off date of last post
- Troubleshooting “loopback requests that take too long”
- How to implement template file and the loop
- Help with if/else loop [closed]
- Why did my most recent article fall behind an older one on my site?
- wp_mail sending only once inside foreach loop
- How to use orderby on meta_value when using Pods custom database table storage