Closed dhruveonmars closed 5 years ago
Hey, I found this post which should solve your issue: https://wordpress.org/support/topic/change-the-order-of-favorites-list/
@Sarah1101 Thanks, though this only reverses the order returned when you use the shortcode [user_favorites user_id="" include_links="true" site_id="" include_buttons="false" post_types="post" include_thumbnails="false" thumbnail_size="thumbnail" include_excerpt="false"]
, but it doesn't affect the order when you use the function get_user_favorites()
.
That seems to be using the default order, which is the date published.
@dhruveonmars Hey, I'm using solution 2 of the post (return array_reverse($favorites);
). The order in get_user_favorites()
is affected too.
@Sarah1101 Thanks! After doing that, and some more testing, it appeared the issue was using include
rather than post__in
as mentioned on WP StackExchange.
What I have also done is array_reverse the array that gets returned in my code, rather than modify the plugin
Is there a way to get the posts ordered by the order they were favourited in? I'm using
get_user_favorites()
with some filters to get posts of a particular category.I've noticed when using the shortcode
[user_favorites user_id="" include_links="true" site_id="" include_buttons="false" post_types="post" include_thumbnails="false" thumbnail_size="thumbnail" include_excerpt="false"]
it displays the posts, with the most recently favourited at the bottom and the oldest at the top.I am using the
get_user_favorites()
function as I have a more customised view, and would like to order it with the most recently favourited item at the top and oldest at the bottom.Any help is appreciated