I haven’t tested this, but it looks like you just need to set an iteration variable (usually abbreviated $i), like this:
<?php
$i = 0; // This sets your variable
$query = [
'post_type' => 'post',
'posts_per_page' => 5
];
$query = new WP_Query($query);
while ($query->have_posts()) : {
$query->the_post();
if($i == 0) :
get_template_part('loops/acc-cards');
else() :
get_template_part('loops/cards');
}
$i++ // This iterates the iteration variable $i
wp_reset_postdata();
?>
Related Posts:
- WordPress query undefined offset in loop
- Problems With Query and/or Template Part and/or PHP
- Query multiple custom post types in single loop
- Inject post (from specific category) between posts in Loop
- Alter query on edit.php
- How to loop over custom fields in a page template?
- Specific Loop For 2 Within Each
- Easiest way to show total number of subpages
- Use template for posts with a particular category grandparent
- spliting posts into two columns
- How to get to a specific position in wp_query?
- Custom excerpt function re-factoring
- Automatically add custom CSS to new posts using a category template
- How can I add extra word in permalink when someone click download button?
- Increase offset while looping
- remove post that has no content
- How to add div blocks after certain set of post
- How to avoid duplicates when creating recent network posts
- How to overwrite orderby with add_query_var
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Issue with custom loop in Archive page
- Only show first image in foreach loop
- How can I get “Previous” and “Next” to show in the navigation besides the links?
- Do not duplicate posts with multiple categories in multiple loops
- Unable to render custom field after attempt to generate a list of recent post in page template
- Limit tags shown in post
- How to pick “full/thumbnail” images in the loop?
- Echo array value
- Wp Query : Order by distance lat,lon
- Advanced Query posts
- Build A Custom SQL Query for WordPress Search
- My Custom Post Type AJAX Query is Returning no posts – why?
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- Check if current post in loop is last on current page
- Is there anyway I can call the year once?
- How to display last whole post on the homepage
- How do if all posts has this category ID then do this
- Let user select the number of posts shown per page jquery error
- Get current_post in reverse order with pagination
- Pagination in WP Queries
- Add div after every 4 posts then every 2 posts for a responsive loop
- Insert div after every three posts in home.php [duplicate]
- Get posts associated with media attachment
- Loop returns more items than exist?
- Automatically create a loop for post ID
- why is this content-template not showing any of my blog-entries?
- Excerpt all post content Content Same Size without word cutting off
- Loop on a wordpress Page instead of content coming from the WP text editor
- How to create a loop that will display one post and stop?
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- Count the number of matching post names in foreach loop
- Need Help With Making Full-Width Template for Blog Posts (common methods aren’t working)
- the_date() not working
- How does printf( __( ) ); work?
- Return HTML Template Page with PHP Function
- On this day PHP code
- get_the_content if it contains multiple lines it results in SyntaxError
- Looking to exclude blog posts from category Previous/Next buttons
- Automatic Excerpt Not Working
- Store loop into array
- Looping through WP_Post Object
- Using a javascript file to access a get posts array
- Link to file in plugin directory from wordpress template?
- Show Custom Taxonomy Title
- Password protecting content in custom template
- How to exclude specific category from the get_the_category(); array
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Trying to make php run in a post
- How to Display a Single Post Excerpt
- Remove posts after a given amount of time
- Hide wordpress field if data is empty in post!
- Echo a hierarchical list of post data from custom fields
- Storing Array from returned database query and using the array in a new query
- Changing layout with wp_customise
- How to show part of the_content?
- Mass update excerpt
- What query string parameter is available for index.php, that works for both pages and blog articles?
- How to set a min number of words for a blog post
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- Get post id in a function when edit/add a post
- get author_name from queried post
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- Change title only in dynamic page
- Query if audio attachment AND/OR custom field
- Loading index.php contents which located outside blog folder for post single page
- get post content of particular post by url
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- How do I define a lookup table that will work across all PHP elements of the template?
- How can I remove the first two words and shorten get_the_title()
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Advice on creating a WP Archive Template with Custom Taxonomy (get_term_meta)
- How to get current post category details inside “loop”?
- create front-end users post list by specific category
- Error display post thumbnails for previous and next post
- Get current taxonomy and display query accordingly
- Give ID to divs inside the loop
- What are the advantages/disadvantages of ways to use php template files?
- Only display notification on single post
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?