Home › Forums › Add-ons › Gallery Field › Empty array when ordering posts by meta_value › Reply To: Empty array when ordering posts by meta_value
I’m digging into the gallery.php
code a little bit and I have a thought as to what the problem is. Let me know if this makes any sense.
This is the code to get the attachments form the database:
// find attachments (DISTINCT POSTS)
$attachments = get_posts(array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post__in' => $value,
));
Is it possible that my $query->set( 'meta_key', 'date_published' );
is affecting this query also, since it’s using get_posts
instead of making a brand new WP_Query
? So in my case, it’s trying to order the attachments by date_published
and since that doesn’t exist, it’s not returning anything? Will investigate further.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.