I have two custom post type Author and Book. The book cpt have an ACF Object Field (authors_object_field) that is related to authors. On the author single page i want to display all books that have the author listed in their ACF Object Field. I'm using Elementor as page builder. I used this code but dont seems to work. Need your lights :)
function my_books_by_author_query($query)
{
$myCurrentAuthorID = get_the_ID();
$meta_query = [
[
'key' => 'authors_object_field',
'value' => $myCurrentAuthorID,
'compare' => '==',
]
];
$query->set('meta_query', $meta_query);
$query->set('post_type', 'book');
}
add_action('elementor/query/booksByAuthor', 'my_books_by_author_query');