You can access the current post ID within the loop via get_the_ID()
while ( $secondary_loop->have_posts() ) : $secondary_loop->the_post();
rating( get_the_ID() );
endwhile;
wp_reset_postdata();
Related Posts:
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- How can I save an array from a random post sequence for later use?
- Include current post into loop
- Loop through array of pages
- Repeat array inside array through while loop
- Issue with WP_Query (need a array of selected ID’s)
- Get post count of current loop when using multiple queries on one page
- Display products from specific category in shop page
- get_template_part in for loop
- “pre_get_posts” firing on every query
- Sort posts by custom taxonomy name
- Use Transient API to cache queries for all posts in all categories?
- Loop inside the loop
- Looping through tabular data
- Show default content if custom WP_Query has no posts
- cloning a WP_Query
- Display featured products through custom loop in WooCommerce 3 [closed]
- meta_query on a date range using an array of values
- How is WP_Query connected to WP_Post in The Loop?
- Multiple WP_Query loops with Pagination Not Working
- WooCommerce Only OnSale Products Loop Snippet [closed]
- Apply CSS class to every second database record [closed]
- How to prevent writing duplicate loops?
- ACF – Get lowest & highest value from field
- query user display_name failed in a custom mysql query foreach
- Query posts by specific word on title
- Multiple taxonomy And acf filter group by
- WP_Query condition affects posts_per_page count
- Custom Search Not Consistent with Results
- Display both standard posts in a specific category along with a custom post type in a single loop?
- Orderby is working with one query but not with other
- Weird orderby => post__in issue
- 1/3 of posts different class
- Two loops on archive page
- Loop Split two Columns
- How to order posts by title after they have already been sorted by category
- How to make a second query offset -2 from current post
- Running main loop 2 times with conditional statement
- Get posts by list of post IDs ordered by those IDs?
- WordPress | Date not always appear [duplicate]
- Array as ‘key’ in WP_Query
- Is_single() conditional tag returns null in query
- Best choice for multiple loop in page?
- Wp_query with 2 meta keys and array of meta values
- Adding a html class based on post count
- Posts in loop all show the same author when there are many authors
- Multiple Rows in a using wp_query
- How to create custom query by keyword in post title?
- If have posts a week old, display, else display a different loop
- Combine 2 arrays in a query parameter
- Create a loop on my pages with new “WP_Query”
- Create a page template for “top rated posts” but show full content and not just a list
- Daily drip of posts – based on user ‘startData’ – ordered oldest to newest
- How to add tax_query to $args with concatenation
- WP ForLoop to compare meta information of posts to determine what post to display
- How to filter query loop block with a search string from the query parameters
- How to split a post and intercalate elements from a loop
- How can I comment comma-separated array values?
- construct complex queries with WP User Query
- How to create a widget like this?
- Different Loop for tag pages?
- Hiding carousel indicators if there’s only one post
- 2 queries with counters
- Does query_posts have an effect on get_the_category?
- Second loop pagination changes URL, not content
- Remove from array in WP_Query loop
- WP Query get only 1 post (sticky, not sticky etc)
- WP_Query not returning correct result with meta_query parameter
- in_array not working on dev server but works on localhost
- Duplice post with standard WP loop – fixed by using query_posts() instead
- Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
- Show custom content when loop or wp query reaches specific time?
- Get categories within specific term
- Custom query for custom post type not getting correct post ID
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- the_post_thumbnail and multiple WP_Query
- I have 3 categories, i want to display on a loop the last 3 of every category
- WP_Query doesn’t works inside loop
- Problem with custom WP_Query and underlying pagination/posts_per_page
- View related categories in order of posts
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- WP_query for posts with same post type AND same post category
- How to solve this script problem in theme directory?
- how to query for meta_value have array
- Show posts in category
- Both WP_Query and get_posts returning 1 post
- WP_Query for attachments without duplicating post_parent and displaying tagged image
- List ALL posts within last week from current category on category page
- WordPress WP_Query Array Custom search via taxonomies
- loop through custom post types with meta data
- Dynamically name array in WordPress loop – add/get values
- Using Query In Post Type Archives
- Creating Custom Query
- Multiple loops on index page with sticky post and pagination
- How to do a loop inside a loop?
- Main loop querying current template’s info only in custom category archive pages, not my posts
- tax_query not working properly with get_posts
- the_excerpt() not working in custom archive
- How can I display sticky posts at first in wp_query?
- Show number of posts AND number on current page (cannot make it work)