• Resolved donnytree

    (@donnytree)


    I am displaying search results in order of number of views or recency. To set the initial search results view to “views” I have this in my code:

    if( !isset($_REQUEST['sorting'])) {
    $_REQUEST['sorting'] = "views";
    }

    However, if I include this code, then if there are no matches, it still displays all of the results for that category. If I remove this code, the search results display correctly. How can I set the default view without destroying the search results? And why does this code affect it??

    Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter donnytree

    (@donnytree)

    A colleague gave me the following advice, which helped, so I figured I would post it in case it helps anyone else:

    “To answer definitively, I would need to see a bit more code.
    Nonetheless, WordPress does override $_REQUEST, so depending on where
    this code is placed, it may be overwritten. So assuming that the
    parameter is being passed in the URL, I would try

    if( !isset($_GET['sorting'])) {
    $_GET['sorting'] = "views";
    }

Viewing 1 replies (of 1 total)
  • The topic ‘custom search results affected by _REQUEST set’ is closed to new replies.