Change default order posts in search results page

WordPress Business Themes Forums Responsive Themes Car Dealer Theme Change default order posts in search results page

Change default order posts in search results page

June 28, 2016
 David

  • David
    Newbie 3 points

    Hi,
    I would like to change the default display order of search results, I use the plugin grdrts (vote plugin) and i would order my listings by number of votes.

    I managed to do it for the home page by creating a shortcode [gdrts-listings] and it work perfectly.

    But for search results is more complicated…

    I just tried to change the url:

    http://www.liste-serveur-minecraft.fr/?s=&tx_version=0&acces–3=&advanced_search=yes&orderby=post_title&order=asc
    to
    http://www.liste-serveur-minecraft.fr/?s=&tx_version=0&acces–3=&advanced_search=yes&orderby=gdrts&order=asc

    This method does not work, I think class_search.php modifies the request, here’s what told me the plugin creator (gdrts):

    MiLLan:
    I am not sure what ‘advanced_search’ parameter is, but it is not part of WordPress. It is possible that you use some plugin for search replacement that is messing with the query. My plugin expands WP_Query WordPress uses for all types of posts queries, but if your search is using something else or modifies the query in some way to ignore changes added by other plugin, then I can’t help you with that.

    What would be the simplest solution?

    June 28, 2016 at 8:56 am
  • Josh
    Josh
    Super Guru 13,887 points

    Hello David,
    You can add your own query under Theme Setup >Page Setup >Search Page >Custom Sort By Options

    June 29, 2016 at 6:02 pm

  • Richard
    Newbie 29 points

    Hello,

    I want to ask how to edit the sort by option.. I only want to appear on the sort option these areas.

    – Popularity
    – Featured
    – Rating
    – Price

    How can I create a custom code for this one?

    Thanks

    October 10, 2016 at 3:22 pm
  • Josh
    Josh
    Super Guru 13,887 points

    Hello David,
    Please go to Theme Setup >Page Setup >Search Page >Custom Sort By Options and add your query to display option you want.
    Popular: orderby=hits&order=desc
    Featured: meta_key=featured&meta_value=yes
    Rating: meta_key=starrating&orderby=meta_value_num
    Price: orderby=price&order=asc

    Example:Price [orderby=price&order=asc]

    October 10, 2016 at 4:15 pm

  • Richard
    Newbie 29 points

    Hello Josh,

    I am Richard.

    What value should I select to the Default Order By so that the Custom Sort By Options will take effect?…

    Thanks

    October 11, 2016 at 1:41 am

  • Richard
    Newbie 29 points

    also what is the code for the query I want?

    Popular [orderby=hits&order=desc]
    Featured [meta_key=featured&meta_value=yes]
    Rating [meta_key=starrating&orderby=meta_value_num]
    Price (low-high)[orderby=price&order=asc]

    it this code will I paste on the custom code section?…

    October 11, 2016 at 3:01 am

  • Julien
    Newbie 14 points

    Hi Josh,

    I want to create this query : first the featured and second the other in alternation. Can you help me?

    Many thanks,

    julien

    October 11, 2016 at 10:00 am
  • Josh
    Josh
    Super Guru 13,887 points

    Hello Julien,
    Please post the code Theme Setup >Page Setup >Search Page >Custom Sort By Options.See attached image.The code will add more sort by option in the search results page.To set a default oderby option in the same section select an option from the ‘Default Order By’ dropdown.Note there is no option the current option in the dropdown.

    Attachments:
    You must be logged in to view attached files.
    October 11, 2016 at 1:21 pm

  • Richard
    Newbie 29 points

    Hello Josh,

    I have added the code. Nothing still not happening my way.

    I only want this four labels but seems all are added.

    What value shall I choose on the dropdown

    Please see attached Image:

    Here is the output:

    See attached image2:

    Attachments:
    You must be logged in to view attached files.
    October 11, 2016 at 2:50 pm

  • Richard
    Newbie 29 points

    Here is the output:
    Please see attached Image

    Seems nothing happens

    Attachments:
    You must be logged in to view attached files.
    October 11, 2016 at 2:51 pm
  • Josh
    Josh
    Super Guru 13,887 points

    The code am providing is meant add the option in the Sort option in the search page (just as your image) so users can click on an option they want.Its not meant to change the default oderby option for the search page.
    If not sure which option to select from the ‘Default Order By’ dropdown select the first option just as my image above.This will display the listings randomly

    October 11, 2016 at 3:05 pm
  • Josh
    Josh
    Super Guru 13,887 points

    The code am providing is meant add the option in the Sort option in the search page (just as your image) so users can click on an option they want.Its not meant to change the default oderby option for the search page.
    If not sure which option to select from the ‘Default Order By’ dropdown select the first option just as my image above.This will display the listings randomly

    October 11, 2016 at 3:05 pm

  • Julien
    Newbie 14 points

    Hi Josh,

    It’s good for me for the featured is in first 😉 but in second I want a randomly order for the listings that is not featured.

    Is it possible?

    thanks for your help

    julien

    October 11, 2016 at 9:05 pm
  • Marie
    Marie
    Super Guru 1,377 points

    Hi Julien,

    There’s no custom query or option to have that sorting feature you want.

    October 12, 2016 at 6:14 am

  • Richard
    Newbie 29 points

    Hello,

    So how can I change the display of the labels so I can take out the title, date, nearest and expires?

    so the remaining labels will just be only Popularity, Featured, Rating and Price…

    Thanks….

    October 12, 2016 at 10:15 am
Viewing 15 posts - 1 through 15 (of 18 total)

Didn't find what you were after?

Chat with us now

or contact our support team