833 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Made it to the Authors' Hall of Fame
  • Has sold $1M+ on Envato Market and is now a Power Elite Author
+8 more
wpbakery says

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)?

Thanks,

Michael

258 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Won a competition
  • Has been part of the Envato Community for over 5 years
+5 more
der says

I kinda don’t understand the question, but here’s the answer according to what I could understand :P

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.

1878 posts YOU TOUCH IT YOU BUY IT
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+6 more
FRESHFACE says
258 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Won a competition
  • Has been part of the Envato Community for over 5 years
+5 more
der says

ah right! :)

833 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Made it to the Authors' Hall of Fame
  • Has sold $1M+ on Envato Market and is now a Power Elite Author
+8 more
wpbakery says

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 :)

258 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Won a competition
  • Has been part of the Envato Community for over 5 years
+5 more
der says

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.

by
by
by
by
by
by