Look closely at $offices
:
array (size=500)
0 =>
array (size=1)
'id' => string '1382' (length=4)
1 =>
array (size=1)
'id' => string '1330' (length=4)
That is not an array of IDs. It’s an array of arrays. $offices[0]
is not '1382'
. It’s an array. So implode()
on $offices
is trying to concatenate arrays, which is what’s causing your error.
The cause of the error is how you’ve used array_map
. If you want to return this meta value for each post in an array, then you should only return the value, not a new array:
$offices = array_map(
function($post) {
return get_post_meta($post->ID, '_octopus_id', true);
},
$query->posts
);
Now $offices
will be an array of IDs, which can be imploded.
Related Posts:
- Inject post (from specific category) between posts in Loop
- Count number of published posts by type
- Get taxonomy terms only of the WP_Query current posts
- Hide post if matches current month and year
- How can I use wp_query to show all product data using just the products ID?
- How to store post ID’s in cookie or session to display the same posts later
- WP_Query: getting posts where custom field exists
- Store metakey value as an array
- Increment paged on WP_Query
- Modify main query before it run without pre_get_post
- Do not duplicate posts with multiple categories in multiple loops
- array_rand not working correctly?
- WP_Query() load selected post
- Wp Query : Order by distance lat,lon
- WordPress sorting posts by date and title using a dropdown
- posts_per_page displays only 2 posts instead of 4 posts
- Query on a repeater date (acf)
- Need to show 7 posts from actual date
- Check the database for a postmeta field
- Getting info about selected posts using one WP_Query
- How to display last whole post on the homepage
- Only Get A Certain Number of Posts From WP_Query
- insert thumbnail image from php script
- Weird Behaviour: Not all WordPress Posts appearing
- List of child pages fetch next results at link click
- Query category-specific, paginated posts and allow viewer to change sort order
- Why does WP_Query show only the same post even with different categories and endwhile?
- How to modify this function to exclude also the post belonging to a specific category?
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- WP_Query | Help me create a search term with an ‘OR’ relation?
- Insert code when users come from an specific referer
- How to display related posts from parent category
- Duplicates with WP_Query loop
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- Use wp_get_recent_posts with search term
- have_posts() execution failure
- Can’t search posts using WP_QUERY inside AJAX Function
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- WP Query with custom Shortcode
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- Loop through categories and display posts title under each dropdown
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Post + form + action + results on the same page
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- auto-populating custom nav with all items from custom post type
- WordPress theme options error
- Get posts from multiple post type
- WP_Query fails despite having 1 post
- Display related posts without a plugin
- How to show an entire post content and not also the excerpt?
- the_posts_pagination() not working in wpquery
- WordPress query undefined offset in loop
- Hide posts if user is added to it WP_query
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- .html end of URl affected to SEO?
- Sort posts in a specific way
- Get the id of all images in a post
- Update if post with specific title exists
- posts_nav_link pulling in multiple post types
- displaying a fall back query if there’s nothing in the post-type category
- Modifying WP URL handing code?
- Free search and custom taxonomy query not providing the same result
- How do I reset $wp_query in a function?
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Advanced Query posts
- Replace a single variable with add_filter
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- Sending simple variable on single page to WP JSON
- My Custom Post Type AJAX Query is Returning no posts – why?
- How to exclude meta no index pages from wp_list_pages
- meta_query search names when they have middle initials
- Define global custom post
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- Don’t update modified post date when user add a product review or comment?
- Limit the number of characters/words in an excerpt for a related posts section
- Posts missing on author page
- get_filtered_term_product_counts – Get product terms if any products
- List all ACF field values across every post on one page
- Closing Comments conditionally in comments.php
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- Having trouble with customizing blog posts on the home page
- Related Posts: if there is no category use tags
- How do if all posts has this category ID then do this
- Query to show average # of months all accounts with specific role have been active
- Query doesn’t display text data with apostrophes
- Getting error in sql query
- Querying posts from wordpress with 2 or more conditionals
- Insert div after every three posts in home.php [duplicate]
- PHP tag in post content makes wordpress go crazy
- SQL Query Search page
- Unable to get Post Category Name and URL
- Dynamically Create Posts Via XML File
- Display Year and Month from custom field + Age Calculator
- WP_Query count of different meta key values [duplicate]
- Masonry layout within the loop
- Trying to see if page is category or single and displaying title with appropriate heading tag
- Add multiple HTML attributes to an Elementor button
- How to sort custom sortable column by custom table value
- /page/2/ redirect to 404