Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: find_related() not limiting #2715

Closed
altendorfme opened this issue Apr 12, 2022 · 2 comments · Fixed by #2719
Closed

BUG: find_related() not limiting #2715

altendorfme opened this issue Apr 12, 2022 · 2 comments · Fixed by #2719
Assignees
Labels
bug Something isn't working good first issue
Milestone

Comments

@altendorfme
Copy link

In version 4.1.0 when using: ElasticPress\Features::factory()->get_registered_feature( 'related_posts' )->find_related( $postID, 4 );, the defined limit is not being respected, it is always showing the default of 5 posts.

Environment information

  • WordPress version: 5.9.3
  • ElasticPress version: 4.1.0
  • Elasticsearch version: 7.2.0
  • Where do you host your Elasticsearch server? Bonsai.io
@altendorfme altendorfme added the bug Something isn't working label Apr 12, 2022
@felipeelia
Copy link
Member

Thanks for opening the issue, @altendorfme!

So, it seems this line should be

$query = $this->get_related_query( $post_id, $return );

While we don't release a version fixing that, the ep_find_related_args filter can be used. Something like the following code should be enough:

add_filter(
    'ep_find_related_args',
    function ( $args ) {
        $args['posts_per_page'] = 4;
        return $args;
    }
);

@altendorfme
Copy link
Author

Hi @felipeelia, fix worked perfectly ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants