837 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Made it to the Authors' Hall of Fame
  • Has sold $2M+ on Envato Market
+7 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

263 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.

1886 posts YOU TOUCH IT YOU BUY IT
  • Won a competition
  • Has been part of the Envato Community for over 5 years
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
+6 more
FRESHFACE
says
263 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! :)

837 posts
  • Power Elite Author: Sold more than $1M on Envato Market
  • Won a competition
  • Made it to the Authors' Hall of Fame
  • Has sold $2M+ on Envato Market
+7 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 :)

263 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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by