More posts by this author and in this category

At the bottom of my blog post template, I want to display links to three more posts by the author of the current post and three posts with the same tag. I feel like there should be a super easy way to do this, as this is such a common use case, but I’m not seeing it. I’ve tried sing the PHP query editor but without success. Is there a Bricks query I’m missing? Or am I putting the wrong things in the PHP editor?
Thanks in advance for your help

Hi Molly,
this code snippet should work for your PHP query editor

$current_author = get_the_author_meta('id');
$post_type = 'post';

return [
  'post_type' => $post_type,
  'author__in' => $current_author,
  'posts_per_page' => 3,
];

As you can see, you can change your logic accordingly for posts of a certain taxonomy.
let me know if this helped.
Cheers Suat

Thanks.
That isn’t working for some reason. Can I do it using meta query instead? Not sure what to put as the key…


This works fine for me, as you can see. I used a custom post type called store for testing, you just have to adjust the code to your needs.

One reason why it might didn’t work for you is, that the PHP Query Editor doesn’t output anything once some other options are selected. Make sure to delete those options beforehand, so the PHP Query Editor can work:

Hope this helps!

That’s done it! Thanks so much!

1 Like