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
- Inside nested wordpress loop (post & post-type) ” in_array()” function can’t retrieve the matching value
- How to filter specific element of an array in wordpress/php?
- adding or removing endforeach; throws error!
- Bootstrap tabs are not being clicked in WordPress loop
- Return to the beginning of the results of a for loop
- How to count posts posts if they are in a separate content page?
- Get gallery in loop through ajax
- Archive: Lists itself
- WP post meta – for loop inside for loop
- Staggering featured post using ‘sticky’
- Adding PHP to an if else loop
- Accordion headings cuts off to second line on collapsing a accordion heading (used acf repeater)
- How to show the last article in a different way in my blog?
- WordPress Recent Posts – Loop
- Exclude category and post from loop in custom category.php
- ACF background-color per post in a WordPress loop
- Show parent category and subcategory once in while loop
- Last post in loop when even
- get_category_parents to array
- How can I get my pagination loop to display the correct number of total pages?
- Notice : Array to string conversion on array_intersect user meta
- Combine multiple queries, array_unique returns nothing
- Store custom field’s multiple values in one user meta key
- Advertisement in Loop Posts wordpress
- Get a specific size from wp_get_attachment_image_src
- How do if all posts has this category ID then do this
- the loop printing post in one grid
- Repeat array inside array through while loop
- Thumbnail wouldn’t scale to size properly
- Remove item from post_meta array via AJAX
- Check value of post meta within IF statement
- Make sticky post with FacetWP
- How to insert content before pagination in loop?
- Pagination on a underscore custom theme
- My WordPress installation doesn’t load correct template
- How to display a loop of custom post types in columns
- Use the loop to check if DB record exists?
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- Plugin error “array_key_exists(): The first argument should be either a string or an integer” [closed]
- 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?
- How to resolve a reload loop issue in the frontend when logged in to WordPress multi-site backend admin area
- WordPress trying to query two custom types to get child from the parent
- Can’t limit posts_per_page in loop
- WordPress loop : how to exclude some posts with their status?
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- WordPress + Isotope: how to give different widths to each entry?
- Date of last blog update for specific authors only?