I’m trying to add a filter to modify the orderby part of the query used in a custom function. I have tried the post_orderby filter and post_request filters and both seem to either cause a timeout when saving trying save functions.php for our Enfold child theme or cause the link to the page to break. The function on its own without the filter works fine. I have posted this in other forums and it was suggested it could be an issue with the filters and theme being used.
Hey Design,
Thank you for the inquiry.
You may need to use the pre_get_posts action hook in order to adjust the posts query. Please check the following link for more info and code examples.
// https://developer.wordpress.org/reference/hooks/pre_get_posts/
Best regards,
Ismael