M
M
mauscode2018-05-07 08:41:11
WordPress
mauscode, 2018-05-07 08:41:11

Filter posts from category with ajax?

Hello!
I have posts from all categories displayed on the main page, I want them to be filtered only by the selected category on Ajax when you click on the filter on top.
5aefe5d06bb09987339691.png
I found an article on how to do this, only there for my taxonomies. Here , and I have a normal post type.
I can make mistakes and write incorrectly, I don’t understand well
. Please tell me how to do this. Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aarty20, 2018-05-18
@aarty20

$args = array(
    'post_type' => 'post',
    'category_name' => $category,  // https://wp-kama.ru/function/wp_query#parametry-kategorij-rubrik
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question