Order by custom field
-
Hi,
As the docs stated,if I want to sort search results by date, then I can use:
<?php echo '<p><a href="' . get_bloginfo('url') . '?s=' . get_search_query() . '&orderby=post_date&order=desc">Order results by date<a></p>'; ?>
Since each of my post has a custom field named as
post_views_count
to keep track of the number of views of this post, so my question is there any way I can sort the search results by this custom field? I’ve tried:<?php echo '<p><a href="' . get_bloginfo('url') . '?s=' . get_search_query() . '&orderby=post_views_count&order=desc">Order results by date<a></p>'; ?>
but it does not work. Thank you very much in advance 🙂
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Order by custom field’ is closed to new replies.