Answer the question
In order to leave comments, you need to log in
How to sort posts in wordpress?
Are there any plugins that could do the following sort?
Answer the question
In order to leave comments, you need to log in
First, learn to google in English, your question has already been asked many times and the solution is googled in 2 seconds.
Secondly, in order to do any sorting (including by rating, by other additional fields), it is enough to know how WP Query works.
You need to pass the $_GET parameter to the current page and pick it up in the script.
For example, a piece of code for displaying posts by publication date:
$postsPerPage = 10;
$page = 1;
$query = new WP_Query(array(
'cat' => 4,
'post_status' => 'publish',
'orderby' => $_GET['orderby'],
'order' => 'ASC',
'paged' => $page,
'posts_per_page' => $postsPerPage));
site.ru/category/?orderby=publish_date
? where the orderby value is exactly what we are passing to the loop. This is just one example. In the case of, say, views, you sort by extra. field (how? google wp query custom fields), since the number of views will be an additional field for you. According to the comments, if I remember correctly, instead orderby=publish_date
of we pass orderby=comments_num
, and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question