开发者

Wordpress Post Sorting?

开发者 https://www.devze.com 2023-02-28 10:17 出处:网络
I to allow my users to sort the list of wordpress posts by Title, Date added, Comments, Rating etc. These will all be buttons or links at the top of the list (kinda like table view sorting)

I to allow my users to sort the list of wordpress posts by Title, Date added, Comments, Rating etc. These will all be buttons or links at the top of the list (kinda like table view sorting)

However, I have no PHP experience and only know a few basics. How would I achieve this? I currently use the following line to sort my posts by name ASC:

<?php query_posts( $query_string . "&orderby=ti开发者_StackOverflowtle&order=ASC" ); ?>

I was personally thinking of the following solution: orderby=VARIABLE1&order=VARIABLE2

Where VARIABLE1 would be set to title by default and VARIABLE2 would be set ASC by default. However I don't know if this is the best solution, and I know even less on how to achieve this.

Thanks for any future help!


Swen, attach ?orderby=title or ?orderby=date to the URLs of your buttons, WordPress will do the ordering itself.


One of the easiest way is just to use the Post Types Order plugin

0

精彩评论

暂无评论...
验证码 换一张
取 消