Example: I'm trying to modify an instantiation of WP_Query by using the posts_orderby filter like so:
add_filter('posts_orderby', 'favorites_orderby');
$new_query = new WP_Query($args);
remove_filter('posts_orderby', 'favorites_orderby');
the favorites_orderby() function is like so:
function favorites_orderby($post_in){
if(is_array($post_in))
$post_in_str = implode(',', $post_in);
return $post_in_str;
}
$post_in is an array that changes based on a previous, separate db query, so I need to be able to pass it into the favorites_orderby() function. Basically it's an array of post IDs that need to get fed to the WP_Query instantiation's ORDER BY parameter so that the resulting db request is set like so: ORDER BY FIELD(ID, 6, 18, 90, 12).
Everything works except passing the array of post IDs ($post_in) to the favorites_orderby()
Any help would be greatly appreciated!