WP_Query provides current_post property inside the loop which starts from 0. So if you want to target first post in the loop you should just check if $the_query->current_post equals 0:
if ( $the_query->current_post == 0 ) {
echo 'is_active';
}
Related Posts:
- Why is this coming back as null? Thats wrong. There is one post
- Two loops on archive page
- Check if loop has any categories?
- How to make search for posts using get method?
- Wp_query with 2 meta keys and array of meta values
- WP_QUERY wrong ammount of posts
- Writing less unnecessary code with WordPress
- How to separate two columns from one content on a page template?
- WooCommerce | AJAX | Product Pagination | Help me implement Ajax Pagination
- Display posts side by side with custom query
- Second WP_Query loop shows data from main query
- Get author meta data with no published posts in author.php?
- Can I force WP_Query to return no results?
- Multiple WP_Query loops with Pagination
- WP_Query and next_posts_link
- Order posts by ID in the given order
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Get array of posts from the current archive page loop
- Get the number of posts from the current page results
- How can I save an array from a random post sequence for later use?
- How to place a loop within another loop?
- In loop: posts have thumbnail AND other variables
- How to order category.php loop by ‘meta_value’?
- Pagination/infinite scroll with WP_Query and multiple loops
- Add inline HTML to posts published within last 24hrs
- Move posts to top of WP_Query if in certain Taxonomy?
- Display different number of posts from one category on the different pages
- Pagination not working Search posts
- How to change a custom query into a standard loop?
- Can certain (site-crashing) limitations on WP_Query in shortcode be overcome?
- Implementing an OR statement to wordpress wp_query
- Get List of all the Authors
- 2 loops on page – one with orderby rand second orderby date
- WP_Query arguments to fetch custom post type posts which are in certain category?
- WP_Query loop within WP_Query loop
- Refine search results using WP_Query
- How to pass many ids in post__in?
- How to show subcategories using loop?
- Counter problem, infinite loop when post_per_page equals X
- Sub-loop / nested loops Best Practices
- Which method is faster to get a single post?
- Show Sticky Post at the top but do not show again in the loop?
- Any number in meta key (wp query)
- How to get all unique categories for posts in loop?
- How do I run through a WordPress loop called from a filter function?
- How do I get the title of a category in a custom loop?
- Using the_post_thumbnail resets current loop item ID
- Out Of memory issue on post per page parameter
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Multiple filter conditions for WP_Query
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- Change query from cat id to slug or name?
- Using Wp_Query without the loop?
- Issue with front page navigation after upgrading to 3.4
- Custom WP_Query id
- Assign custom parameter to each post in query
- Custom WP_Query doesn’t display all posts
- Exclude recently updated post from custom WP_Query using multiple loops
- get_posts output always same post
- How to use WP_Query() on single.php?
- How can I prevent posts with no title showing up in my query?
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Loop increase in while loop not working
- How does WP generate the default $query in WP_Query based on the URL?
- how to get category`s slug in WP_Query loop?
- How to remove only the latest sticky post from the loop
- How I can repeat 2 HTML templates in a WordPress Query?
- Does putting queries within loops cause an issue on WordPress?
- How to create Page templates for showing Blog posts in different layouts?
- WP_Query not getting all posts, just tagged posts
- Offset WP_Query by negative 1
- WP_Query orderby random do not repeat infinite scroll – one loop
- Advise on Templates for Custom Queries
- Query WP Page for Buddypress Group Home [closed]
- $post in wp_query?
- How to pass the current content of $wp_query to a new page?
- Can I alter the main loop to ‘orderby’ a custom callback?
- Custom WordPress post query for displaying time-released content on website
- Avoid removing duplicate posts
- Regarding a custom loop and output HTML tags
- Repeat array inside array through while loop
- What’s causing an infinite loop?
- pages shortcode filtering by category
- Meta Query if Values Don’t Exist
- Get post Number with local loop and template
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- query_posts() doesn’t seem to be called in my page
- display post multiple times based on array of dates
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Load 3 posts in flexslider slide [closed]
- Issue with WP_Query (need a array of selected ID’s)
- Multiple wp_query loops showing first 5 posts on all pages instead of older posts[Resolved]
- Next / previous posts link doesn’t show up with Posts 2 Posts
- How to exclude posts ordered by comment_count from subsequent wordpress loops using WP_Query?
- $query conflicting with other queries in the same page
- WordPress Post Looping? [duplicate]
- Carousel Loop only duplicating
- How to show featured post first, then separate loop for other posts
- How to display posts from a specific term first then another posts from another terms using tax_query
- Query All Posts: Either Display Most Recent or One with Particular ACF Value Chosen