Timber\PostQuery – query on ACF fields
-
I have an author archive page for a WordPress author that doesn’t have any Posts that shows zero posts. I have an ACF field that allows me to add this WordPress user as a “secondary author” to select blog Posts and I would like to modify the default query for this particular author archive page so that I can get posts that include that author in the ACF secondary authors field.
I’m using \Timber\PostQuery and would like to continue using it because it gives me an easy way to do pagination.
Is this possible and if so, any suggestions on how I would do this? I’ve tried the following so far but nothing works:
global $wp_query; $wp_query->query = [ 'meta_query' => [ 'relation' => 'AND', [ 'key' => 'secondary_authors', 'value' => 'SOME_VALUE', 'compare' => 'IN' ] ] ]; $context['posts'] = new Timber\PostQuery($wp_query);
This doesn’t work – the author archive page in question still shows no posts. I’ve tried printing out $wp_query and simply changing the author to a different author to see if I can force all author archive pages to show the posts for that hard coded author and that doesn’t even work. It appears that modifying $wp_query and passing it into the \Timber\PostQuery class constructor when instantiating it doesn’t do anything.
I’ve also tried the
posts_pre_query
filter but it doesn’t fire for an author archive page that doesn’t have any posts.The page I need help with: [log in to see the link]
- The topic ‘Timber\PostQuery – query on ACF fields’ is closed to new replies.