0

I have created a hyper link in the bottom of each "news" page which goes to _layouts/15/osssearchresults.aspx. The reason is I want to show all "News".

So I changed the href of hyperlink to _layouts/15/osssearchresults.aspx?k=contentType:NewsCT. It works and it shows all news.

However they are not sorted based on created date. I thought if I change the query (href) to ?k=contentType:NewsCT AND sortlist='created:descending' it would work but it didn't. I have tested some other queries but not succeeded yet.

2 Answers 2

3

If you want to append to the url, you can add something like this -

osssearchresults.aspx#Default={"k":"Amit","o":[{"d":1,"p":"Created"}]}

Above, k = queryText ; d - can be 0 or 1 for specifying the sorting order ; p - parameter based on which you want to sort. Further you may look into this link

Also if you are using result source for search results, you have the option of sorting under the Sorting tab. There you can choose the Created field and select the sort order.

Hope that solves your query.

0
1

First of you should use SPContentType and not ContentType. For some reason ContentType seems a bit unstable but the "special" SPContentType always works.

In addition to the suggestions by @Sane.Amit you can edit the search result web part and change the sort order drop down values, then uncheck it again as explained in my post: http://techmikael.blogspot.no/2013/06/how-to-change-default-sort-of-search.html

But I tend to go the Result Source way myself. Very flexible and easy to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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