You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The Algolia_Search::pre_get_posts() method uses the posts_per_page option for the value of the hitsPerPage index search parameter.
Describe the solution you'd like
Use the value of hitsPerPage in the call to $query->set( 'posts_per_page', $params['hitsPerPage'] );, so that a filtered hitsPerPage value does not throw pagination off.
Describe alternatives you've considered
Hook into pre_get_posts with a custom function in theme, on a later priority, and $query->set( 'posts_per_page', $my_custom_hits_per_page_value );. I'm not convinced that would work, and it seems kinda gross, since we could just handle it gracefully in the Algolia_Search::pre_get_posts() method. We could also provide a filter for $posts_per_page but then we run the risk of $posts_per_page and hitsPerPage not matching.
Additional context
Some plugins and themes do not use the value of posts_per_page in their custom search pages. In those circumstances, site owners may experience confusing issues revolving around pagination. Asking them to filter hitsPerPage does not resolve their issues, again, due to the later use of posts_per_page in $query->set( 'posts_per_page', $posts_per_page );. See this WPORG support issue for additional context.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The
Algolia_Search::pre_get_posts()
method uses theposts_per_page
option for the value of thehitsPerPage
index search parameter.The
algolia_search_params
filter allows you to modify thehitsPerPage
value, but doing so throws pagination off, asposts_per_page
is also used in a call to$query->set( 'posts_per_page', $posts_per_page );
in the same method.Describe the solution you'd like
Use the value of
hitsPerPage
in the call to$query->set( 'posts_per_page', $params['hitsPerPage'] );
, so that a filteredhitsPerPage
value does not throw pagination off.Describe alternatives you've considered
Hook into
pre_get_posts
with a custom function in theme, on a later priority, and$query->set( 'posts_per_page', $my_custom_hits_per_page_value );
. I'm not convinced that would work, and it seems kinda gross, since we could just handle it gracefully in theAlgolia_Search::pre_get_posts()
method. We could also provide a filter for$posts_per_page
but then we run the risk of$posts_per_page
andhitsPerPage
not matching.Additional context
Some plugins and themes do not use the value of
posts_per_page
in their custom search pages. In those circumstances, site owners may experience confusing issues revolving around pagination. Asking them to filterhitsPerPage
does not resolve their issues, again, due to the later use of posts_per_page in$query->set( 'posts_per_page', $posts_per_page );
. See this WPORG support issue for additional context.The text was updated successfully, but these errors were encountered: