-1

I search for a solution how i can sort the article in my page.

I searched for hours in google and try severla things but nothing works :( .

Anyway, maybe anybody has a good tip for me.

I want a simple list with options for sorting like "newest first" or "relevance" or "alphabetically (Entry Title)".

Any Ideas?

  • 2
    searched for hours in google and try severla things - doesn't say anything clear. What exactly you tried and how they failed you? Please explain the way you are using the things you are getting. – Mayeenul Islam Nov 18 '13 at 11:26
  • Thats my problem ... i found nothing which is passed for my situation, i dont want to sort any custom fields ... only a simple bar at the top where i can sort like the following example ... but the code are dont working ;) <code> <ul id="sort"> <li><a href="&sort=top-rated">TopRated</a></li> <li><a href="&sort=new">Newest</a></li> <li><a href="&sort=popular">Most Popular</a></li> <li><a href="&sort=relevance">Relevance</a></li> </ul></code> – R.Kalk Nov 18 '13 at 12:46
0

You can order your posts by several strings that are available in WP.

The normal way is by alphabetizing or via a plugin. You have the option between order by name or date.

But if you want to order your posts by custom tags eg. "most popular", "relevance",... Then you could custom code that in by following the reference here.

The snippet for ordering by "most popular" for example is:

<?
query_posts('meta_key=post_views_count&orderby=meta_value_num&order=DESC');
?>

Or by "most views":

<?php $posts_per_page = get_query_var('posts_per_page'); ?>
<?php $paged = intval(get_query_var('paged')); ?>
<?php $paged = ($paged) ? $paged : 1; ?>
<?php $args = array(
   'posts_per_page' => $posts_per_page,
   'paged' => $paged,
   'more' => $more = 0,
   'meta_key' => 'views',
   'orderby' => 'meta_value_num',
   'order' => 'ASC',
); ?>
<?php query_posts($args); ?>

You'll have to program a series of functions depending on what you want...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.