-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add filter when building WP_Query arguments #1412
Conversation
Allow to customize the arguments for WP_Query created by build_articles_query using the new filter 'newspack_blocks_build_articles_query'.
Thanks @alexmerz , Could you please add a doc block to the new filter? Please have a look at the WP coding standards here https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#4-hooks-actions-and-filters |
@leogermani Doc block is added, feel free to adjust the "since" argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
# [2.6.0-alpha.1](v2.5.0...v2.6.0-alpha.1) (2024-01-11) ### Features * add filter when building WP_Query arguments ([#1412](#1412)) ([f960bd6](f960bd6))
🎉 This PR is included in version 2.6.0-alpha.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.6.0](v2.5.0...v2.6.0) (2024-01-25) ### Features * add filter when building WP_Query arguments ([#1412](#1412)) ([f960bd6](f960bd6))
🎉 This PR is included in version 2.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Allow to customize the arguments for WP_Query created by build_articles_query using the new filter 'newspack_blocks_build_articles_query'.
All Submissions:
Changes proposed in this Pull Request:
Our websites make heavy use of the Homepage Articles block on the Homepage and related type of pages. This results in a significant amount of slow WP_Query calls by the Homepage Articles blocks in case of a cache invalidation caused by new post publications or content changes to these pages. The underlying reason for the slow queries is the default usage of SQL_CALC_FOUND_ROWS by Wordpress. As this seems not to be necessary for a Homepage Articles block, it would be usefull to set the argument 'no_found_rows' for WP_Query in such situations.
But as such a change might break other existing code in the plugin or third party usage, the best way seems to add a filter to build_articles_query() to allow users to add such an argument in a filter when usefull.
I our case we were a able to reduce the time to generate the Homepage from 24 seconds down to 13 seconds by adding the filter and add the 'no_found_rows' argument in the custom filter.
Closes # .
How to test the changes in this Pull Request:
Other information: