Answer the question
In order to leave comments, you need to log in
Wordpress get_posts(), how to sort received posts with a specific one?
Suppose there is a category with id=123 and in this category I display 5 entries with id=1,2,3,4,5.
How can I form get_posts() to display posts starting from the 3rd, i.e.
{record 3, record 4, record 5, record 1, record 2}
Is it even possible to do this?
And if not, then another question. Is it possible to get the post/record number?
Answer the question
In order to leave comments, you need to log in
If you mean the order of the posts in the category, then there are no such serial numbers for the posts
When requesting get_posts(), you can use the argument 'orderby' => 'ID'
to sort by this field, sorting will work from record 1 or in reverse order from record 5 if you change the 'order'
Id argument can be obtained without problems using the get_the_ID() function in a loop
Well, if the question is only in the order of output, then you can use plugins like "post types order"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question