1

I want to stop this query from running:

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_author IN (1) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 3

Apparently https://developer.wordpress.org/reference/hooks/query/ can be tried for this. But if I try the following code in functions.php of the active theme:

apply_filters( 'SELECT SQL_CALC_FOUND_ROWS wpxt_posts.ID FROM wpxt_posts WHERE 1=1 AND wpxt_posts.post_author IN (1) AND wpxt_posts.post_type = \'post\' AND (wpxt_posts.post_status = \'publish\') ORDER BY wpxt_posts.post_date DESC LIMIT 0, 3', string $query ) (escaping quotes)

or:

apply_filters( 'SELECT SQL_CALC_FOUND_ROWS wpxt_posts.ID FROM wpxt_posts WHERE 1=1 AND wpxt_posts.post_author IN (1) AND wpxt_posts.post_type = 'post' AND (wpxt_posts.post_status = 'publish') ORDER BY wpxt_posts.post_date DESC LIMIT 0, 3', string $query )

There are errors. How should this be used in this case?

Edit: The 'duplicate' given does not explain how to use the https://developer.wordpress.org/reference/hooks/query/ function as this question is asking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.