Guys, do you know a good way to filter wordpress post inside of the category view template?
What is the best way to give user to filter/order posts by date, popularity, style (set by tag or category)?
I kinda don’t understand the question, but here’s the answer according to what I could understand
To filter the posts pertaining to a specific category, you need to create the category.php file, and then include The Loop inside it.
To filter by date, you can use the archive.php file, then including The Loop on it.
To filter by tags, then use the tag.php file.
If you want to have a better idea, have a look at the Template Hierarchy.
- Bought between 100 and 499 items
- Referred between 200 and 499 users
- Author was Featured
- Has been a member for 4-5 years
- Author has had an Item Featured
- Won a Competition
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 250 000 and 1 000 000 dollars
Thanks for the suggestions, but that doesn’t looks like “the thing” I’m looking for..
I need to have some kind of interface, where user with mouse will click “order by date” or “order by popularity”, “comment count”, “another parameter” – which could be set during the post creation.
Let’s imagine that I have a website with music bands, so the user should be able to filter/sort posts by genre, alphabetically and etc.
I hope I’ve explained better this time
In that case you would need that integrated into the theme’s options, using a dropdown menu. You can then use the document that _freshface provided, to see the available sorting methods.
Then you perform the query with the option specified in the admin panel. For example, if you include an option that says ‘Order Posts by Date’, then its value would be ‘date’. Then on The Loop you would run
query_posts('orderby=' . $order_option);
In the example,
$order_option is the value you retrieved from the theme’s options.