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
- Get post content from outside the loop
- How to Change Loop to Order Posts by Views (using wp-postviews plugin)
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?
- Display subpages under parent page as a list within a loop
- When to use wp_reset_postdata();
- Related Posts loop – offset
- Random post, page inside post loop problem
- How to change post count in wordpress loop?
- WordPress loop specific thumbnail size
- single page site with subpages
- Different Queries Return Same Results [closed]
- wordpress simple loop, huge issues
- Pagination gives extra page with no results
- Cannot display or echo alt text on featured image
- Using Advanced Custom Fields to create a per page slider
- WordPress Search Results for Multiple Post Types
- Query reset problem or flawed code to enable custom post type query
- Exclude posts from main loop based on meta value
- Blog page Server error 500 with stick post loop in query.php
- Show all posts using the template page and the loop?
- Custom loop not working
- Escape current post from loop
- Why isn’t my multiple loops working?
- facebook like, tweet and google+1 buttons inside the loop on home, archive and search pages and missing facebook like buttons
- Loop Offset for tag based “Related Posts”
- How do I put my frontpage featured image in a page template for home.php?
- Echo array value
- How to filter posts by category INSIDE the loop
- How to break up php code to avoid echo
- static page with multiple loops breaks post pagination
- Help with if and else statement
- Products listing check if meta checkbox is checked
- How to filter specific element of an array in wordpress/php?
- is it bad to copy the loop for a template?
- I want to load post in bootstrap Modal dynamically
- View tag description on page
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Return only one post format in index.php [duplicate]
- How to display just video post format?
- How to execute custom loop before loop content?
- Sorting posts to make those with post thumbnail show up first
- Best way to check if a post with specific meta exists
- get_posts and wp_autop (remove filter)
- Trouble preventing duplicate posts between 2 loops on homepage
- How can I put a custom field as the link of a button shortcode?
- is there away to hide php code in wordpress not to show in PAGES
- Error in Wordprewss loop for page template [closed]
- Hook in the loop after the first post