How to use the query hook/filter?

Question

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.

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/how-to-use-the-query-hook-filter/">

How to use the query hook/filter?</a>
0
, , , user178785 2 months 0 Answers 22 views 0

Leave an answer