Looking at your code – $lastarray will not be an array of ID’s (as you might be expecting), but an array with a single element containing a string of comma separated IDs.
$output is already an array of the $attr[‘id’] – try commenting (add // to the start) to the lines starting with $testarray and $lastarray and replacing 'post__in' => $lastarray with 'post__in' => $output
See if that helps.
Edit: to clarify – post__in expects an array (rather than ‘id’,’id’,’id’ string) – see here
Jon
Related Posts:
- Output meta into arrays
- Endless loop with wp_insert_post and wp_update_post
- Add Incrementing ID to each paragraph in the_content
- In a foreach loop, how do I target the last item in the loop?
- Looping through WP_Post Object
- How to iterate through database until it find a match
- Must Use Plugin Causing Query Error
- How can I add multiple ‘tax_query’ arrays via a loop?
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- How to print out menu names in the foreach loop?
- Checking array against author id in loop
- Problem with displaying HTML content after in_array [closed]
- Add class to last 3 posts in loop
- Array ids post to function have_post
- Can’t access PHP array inside script localization from javascript
- Trying to get property of non-object in shortocde
- Need to add class to first element in a foreach loop
- Foreach displays from last to first
- How can I access specific posts brought back by query_posts?
- How to create a multidimensional array with multiple loops
- Simple foreach loop help needed in wordpress “the loop”
- How to get the last category name of a child category?
- How to access or parse key/values that have “string”
- WordPress loop by meta key that is an array? and how loop multiple arrays
- How to get user ID’s from multiple usernames?
- Only show first image in foreach loop
- Get all posts as an array ID => Name
- Loop through an array inside a class using foreach [closed]
- How to print redux gallery feilds id? [closed]
- CPT while loop not working
- display post tags on single.php inside loop
- Exclude posts based on an array
- How to check all items in a loop have post thumbnail?
- Add 2 values to post__not_in
- in_array not working on dev server but works on localhost
- ACF – Get ID of relationship field in flexible content
- Show the subcategory name based on current product
- Query posts and display all dates in repeater field in chronological order
- Get featured image outside the loop using foreach
- Why loop renders only last metabox from array? [closed]
- WP_Post is not from correct array
- Create Customization Controls from Array
- Foundation modal in wordpress php loop
- ACF field not appearing correctly in loop
- Can’t print out returned value
- WordPress loop: Display if posts exist
- How can I access ‘key’ and ‘value’ from an array in a for 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
- How to get files from loop for zip
- How can merge two arrays values in one array and save in database
- Installing wp3.2.1 on IIS; getting empty sessions
- Where should I use post_class()?
- How to paginate this custom loop? [duplicate]
- Select data from database and list it in Loop (WordPress)
- I’ve been out of the loop since 2.8. What did I miss?
- Loop first six posts in carousel, next eight in grid
- Infinite blog loop
- One custom loop with condition to check child posts
- Loop get_theme_mod
- Dynamic Stylesheet loads but doesn’t finish
- Template structure
- Filter the_posts doesn’t work on search page
- Only showing the_date and the_excerpt for first entry in get_posts
- Include multiple page ids in loop
- Assign custom parameter to each post in query
- Conditional multidimensional arrays and array_map
- extract serialized array to use for wp-query
- Call wp-blog-header.php header without performing a wp_query
- Display post formats differently on index.php (loop in function)
- How to output thumbnail twice in a loop
- How to make sure relative URL works when site is not on root domain?
- Get URI from PodPress using PHP
- Display more than 10 posts on author.php file
- Display all categories as plain text
- Forcing page to top of the list when using get_pages
- How do I get pagination for get_posts() in WordPress or do I have to rewrite the whole code?
- how to separate an array into different arrays and save them into db?
- How to display fields from the loop in two separate divs
- Duplicate posts on archive page
- Adding PHP to an if else loop
- Pagination on a underscore custom theme
- Build a Page which shows the Oldest Post with specific Custom Field Value
- WordPress multiple loops with default pagination
- Loop random posts and display odd and even based on two alternating meta values?
- get_users when from meta key that has serialized values
- make an array in wordpress cusmization api?
- Style first 3 posts differently and use a 2nd loop to get rest of posts / offset and pagination broken
- Posts Per Page is Not Returning Correct Number
- Display a post based on its metabox selection
- Set loop format & have a loop inside other one
- stuck with template hierarchy
- How to create an identical second loop for attachments?
- How to call the_author_meta and make it work?
- Getting Post Permalink Outside of Loop Not Working
- Lists Top Authors by Most Recent Posts
- pull 500 post of many from database [duplicate]
- WordPress loop put title into variable
- Landing page with login