Relevanssi - A Better Search
[resolved] [Plugin: Relevanssi] Sorting 'oldest to latest' does not work (6 posts)

  1. nhowarth
    Posted 5 years ago #

    I'm trying to give users to sort results as follows:

    <a href="<?php bloginfo('url');?>?s=<?php echo get_search_query();?>">Relevance</a>
    <a href="<?php bloginfo('url');?>?s=<?php echo get_search_query();?>&orderby=post_date&order=desc">Newest</a>
    <a href="<?php bloginfo('url');?>?s=<?php echo get_search_query();?>&orderby=post_date&order=asc">Oldest</a>

    Relevance and Newest work fine, but Oldest does not (it produces the same results as Newest).

    Any thoughts?

    Thanks in anticipation

  2. Mikko Saari
    Plugin Author

    Posted 5 years ago #

    I just tested this on my test blog and everything worked just fine. The results come out in correct order and switch order like they should when I change the order parameter.

    The function is a bit picky, as the parameter must be exactly "asc" for it to ascending sort, anything else (even ASC or something like that) and it's a descending sort.

    So, I'm guessing that for some reason the parameter isn't being passed as it should.

    You could try adding


    after line 952, which looks like this:

    isset($wp->query_vars["order"]) ? $order = $wp->query_vars["order"] : $order = 'desc';

    Then click the link with the ascending order and see what the var_dump says.

  3. nhowarth
    Posted 5 years ago #

    Thanks Mikko for getting back to me so quickly.

    I added var_dump($order); as suggested and everything worked OK.

    I guess there must have been something in my cache that was causing the problem.

    Thanks for your help.


  4. Mikko Saari
    Plugin Author

    Posted 5 years ago #

    Good to hear you got it solved. Hope you like Relevanssi!

  5. nhowarth
    Posted 5 years ago #

    It's great Mikko,

    I have just completed installing it on my live site Cyprus Property News.



  6. Mikko Saari
    Plugin Author

    Posted 5 years ago #

    Very nice. Thanks for using Relevanssi!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relevanssi - A Better Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic