Sort by custom field that is an array?
is it possible to sort posts inside a query based on post value that is in an array – but using the last element of the array?
The code looks something like:
<?php $mostsharedposts= new WP_Query( array( 'posts_per_page' => 10, 'meta_key' => 'mashsb_shares', 'orderby' => 'meta_value', 'order' => 'DESC' ) ); while ( $mostsharedposts->have_posts() ) : $mostsharedposts->the_post(); /* Loop here e.g.:*/ endwhile; ?>
meta_value is an array, and I just need the last element of that array. Can I somehow extract that element in a variable, using
end() and sort by that variable or …?
Any idea would be helpful 🙂