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?
- Display both standard posts in a specific category along with a custom post type in a single loop?
- How do I get the title of a category in a custom loop?
- WordPress Loop and $post
- Group and list posts by custom taxonomy
- Show scheduled posts in main loop but not in WP_Query?
- Change query based on post type while staying in loop
- Using the_post_thumbnail resets current loop item ID
- Filtering posts from different categories into different section by doing WP_Query only once
- Orderby is working with one query but not with other
- Import wp users via one click demo option
- Get a list of posts with associated meta_value
- How can I use $wp_query->tax_query as tax_query parameter for a new WP_Query instatiation?
- Show post number in widget loop
- Order by empty custom field
- posts_per_page not working for first page of pagination
- 1/3 of posts different class
- Adding column to wp_posts table or join wp_posts table with another table
- Out Of memory issue on post per page parameter
- $WP_Query: How to display excerpt on first post only
- Loop Performance > JSON files vs. WP_Query vs. REST API
- Loop Split two Columns
- How to order posts by title after they have already been sorted by category
- Excluding pages in WP_query using ACF
- reset to main loop doesnt work
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Some doubts about how the main query and the custom query works in this custom theme?
- Search form not working with custom query?
- Post loop for all taxonomy terms
- WordPress ignoring LIMIT / posts_per_page despite being in wp_query
- Stuck in the query loop
- Conflict with get_posts and the_content
- How to get list of posts from permalinks?
- Multiple filter conditions for WP_Query
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- New WP_Query loop in admin causes problems
- How to list posts with disabled/closed comments, with pagination?
- How to make a second query offset -2 from current post
- Running main loop 2 times with conditional statement
- Inside a loop, how to change CSS class based on category name?
- Only display post if published in last 24 hours?
- Need to convert string of term ids into comma separated integers for use in an arguments array
- Redirect to another page using contact form 7? [closed]
- WordPress | Date not always appear [duplicate]
- Custom taxonomy.php not working
- Array as ‘key’ in WP_Query
- How to remove the most recent post from $the_query
- different for loop if screen resolution < 1000px
- Reset WordPress Post Query to default
- WP_Query loop else statement not executing
- Change query from cat id to slug or name?
- How do I get my custom query to work with search results after the first page?
- Using Wp_Query without the loop?
- Is_single() conditional tag returns null in query
- How do I rewrite this loop as a new WP_Query style-loop?
- Transient api Caches confused
- Issue with front page navigation after upgrading to 3.4
- Include current post into loop
- What happens to the default query when I use WP_Query?
- Custom WP_Query id
- Best choice for multiple loop in page?
- get_template_part causes 500 error
- WP Query – order posts by meta field first and then order the rest
- How to Create a Random List of Child Pages
- How to display the featured image for each post?
- Assign custom parameter to each post in query
- How to provide meta_key array to wp_query?
- Adding a html class based on post count
- Check for the main query from the template
- how to use pre_gets_posts to exclude one queried ID from homepage loop
- Custom WP_Query doesn’t display all posts
- Trying to retrieve random post, getting a page
- Posts in loop all show the same author when there are many authors
- Exclude recently updated post from custom WP_Query using multiple loops
- get_posts output always same post
- Multiple Rows in a using wp_query
- How to show one post different from the rest?
- How to use WP_Query() on single.php?
- sort and display posts by custom field (wp-query and the loop))
- 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?
- WP_Query with custom post type ID
- How to create custom query by keyword in post title?
- difference between querying database and using the loop
- If have posts a week old, display, else display a different loop
- WP_Query – Adding “offset” posts to the end of the loop
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields