D
D
denism3002020-07-23 22:03:13
WordPress
denism300, 2020-07-23 22:03:13

How to get all posts from the current request?

I need to get all posts in the current request.

global $wp_query;
$posts = $wp_query->posts;

works fine if there are no parameters.
For example, if I make a selection by meta parameters
meta_key=color&meta_value=blue

adding them as a GET to the link, the posts are displayed correctly, however,
$posts = $wp_query->posts;
all posts are transferred here, without taking into account the selection by parameters
How can I get the posts in the current request, taking into account the selection by parameters?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question