Brad Fletcher
Brad Fletcher

Reputation: 3593

Wordpress Search Results in Order

One of my clients websites, www.kevinsplants.co.uk is not showing the search results in alphabetical order, how do I go about ordering the results in alphabetical order?

We are using the Shopp plugin and I believe its that plugin that is generating the results!

Cheers, Brad

case "orderby-list":
            if (isset($Shopp->Category->controls)) return false;
            if (isset($Shopp->Category->smart)) return false;
            $menuoptions = Category::sortoptions();
            $title = "";
            $string = "";
            $default = $Shopp->Settings->get('default_product_order');
            if (empty($default)) $default = "title";

            if (isset($options['default'])) $default = $options['default'];
            if (isset($options['title'])) $title = $options['title'];

            if (value_is_true($options['dropdown'])) {
                if (isset($Shopp->Cart->data->Category['orderby'])) 
                    $default = $Shopp->Cart->data->Category['orderby'];
                $string .= $title;
                $string .= '<form action="'.esc_url($_SERVER['REQUEST_URI']).'" method="get" id="shopp-'.$Shopp->Category->slug.'-orderby-menu">';
                if (!SHOPP_PERMALINKS) {
                    foreach ($_GET as $key => $value)
                        if ($key != 'shopp_orderby') $string .= '<input type="hidden" name="'.$key.'" value="'.$value.'" />';
                }
                $string .= '<select name="shopp_orderby" class="shopp-orderby-menu">';
                $string .= menuoptions($menuoptions,$default,true);
                $string .= '</select>';
                $string .= '</form>';
                $string .= '<script type="text/javascript">';
                $string .= "jQuery('#shopp-".$Shopp->Category->slug."-orderby-menu select.shopp-orderby-menu').change(function () { this.form.submit(); });";
                $string .= '</script>';
            } else {
                if (strpos($_SERVER['REQUEST_URI'],"?") !== false) 
                    list($link,$query) = explode("\?",$_SERVER['REQUEST_URI']);
                $query = $_GET;
                unset($query['shopp_orderby']);
                $query = http_build_query($query);
                if (!empty($query)) $query .= '&';

                foreach($menuoptions as $value => $option) {
                    $label = $option;
                    $href = esc_url($link.'?'.$query.'shopp_orderby='.$value);
                    $string .= '<li><a href="'.$href.'">'.$label.'</a></li>';
                }

            }
            return $string;
            break;

Upvotes: 0

Views: 1973

Answers (3)

RST
RST

Reputation: 3925

It is not a good idea to edit the core code. And lucky for you it is not necessary. You can edit/create your own template file collection-search.php and style it any way you want.

There is more info on template files here.

Upvotes: 0

Matanya
Matanya

Reputation: 6346

You need to edit the template file of the search page and add to the search query parameters orderby title, as opposed to the default ordering which is by time of publication

Upvotes: 0

Brian
Brian

Reputation: 351

http://wordpress.org/extend/plugins/sort-searchresult-by-title/

This is a plug-in that seems to do what you want.

Upvotes: 0

Related Questions