Need some help: trying to sort admin column based on an acf within a post object

I have a question about sorting admin columns based on an acf, and the ‘post_title’ within within a post object.

I am following this set up here – https://www.ractoon.com/2016/11/wordpress-custom-sortable-admin-columns-for-custom-posts/

Here is the code I have that is working and sorting based on the ‘job_snapshot_job_location’, but I need to get within that post object and grab ‘location_city’ in one instance and the ‘post_title’ in another instance.

function custom_orderby( $query ) {
if( ! is_admin() )
return;

$orderby = $query->get( ‘orderby’);

if ( ‘city’ == $orderby ) {
$query->set(‘meta_key’, ‘job_snapshot_job_location’); // This needs to go into the post object and get the value for city, ‘location_city’, or in another instance the ‘post_title’
// ‘job_snapshot_job_location’ is the post object
$query->set(‘orderby’,’meta_value’);
}
}

Any direction or help appreciated.

Read more here:: Need some help: trying to sort admin column based on an acf within a post object

Leave a Reply

Your email address will not be published. Required fields are marked *