google-code-export / wordpress-custom-content-type-manager

Automatically exported from code.google.com/p/wordpress-custom-content-type-manager
2 stars 1 forks source link

Implode() output filter #432

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If using an Is Repeatable field , for example I am storing multiple users in a 
Users field. I then need to return those stored values as a string for using in 
WP_Query. An implode() feature would be useful to return multiple values as a 
string.

For example, Users is a custom field and is repeatable. I want to bring back a 
list of users associated with a post.
Currently WP_Query will only query meta_key, meta_value pairs when meta_value 
is returned as a string, not an array.

$args = array(
'post_type' => 'projects',
'meta_query' => array(
array(
'key' => 'project_owner',
'value' => 2,
)
)
);

project_owner values are returned as an array, 
The value parameter only expects a string to be returned

Is there a way do to this?

Original issue reported on code.google.com by kb6...@gmail.com on 24 Nov 2012 at 6:51

GoogleCodeExporter commented 9 years ago
It's just a matter of iterating over the array and looking up user data.

For basic "implode" operations, use the "to_formatted_list" filter: 
http://code.google.com/p/wordpress-custom-content-type-manager/wiki/formatted_li
st_OutputFilter

Also see 
http://code.google.com/p/wordpress-custom-content-type-manager/wiki/to_array_Out
putFilter  -- You see why I avoid WP_Query and instead wrote the GetPostsQuery 
class: you can pass it an array of values directly (as one example).  

Since this is more of a "how do I" question and not a bug, it's more 
appropriate for the forums.

Original comment by ever...@fireproofsocks.com on 25 Nov 2012 at 1:43