Support » Plugin: SearchWP Live Ajax Search » Add link to view all results?

  • Resolved jasonkadlec


    I like the default of 7 results returned… but I do want to be able to allow users to click to the .com/?s=search-query page to view all results.

    I can use some javascript to grab whatever they typed into search field, and then use that to set the href of the link… but hoping there would be maybe something PHP based that I could hook onto and just echo in the search-results.php template that I’ve copied into the theme.



Viewing 3 replies - 1 through 3 (of 3 total)
  • Update ( not solved yet) — it looks like search-results.php should just work like whatever would be used on search.php in a default theme… however


    as well as


    are both NULL….

    Maybe javascript really is the way to go since once the search is open…the user can keep typing which keeps interacting with the search, so the “view all” link should be keeping track of/live updating itself to whatever is actually getting typed in… hmmm.

    Ah so easy!

    I’m using a search form, and so I updated the button to say “view all results” – when clicked, it submits the form / page redirects to the .com/?search=etc-etc

    No need to put a link at the bottom, just use a button next to the input field which will submit the form.

    Plugin Author Jonathan Christopher


    Hi there! Just to follow up on the original inquiry:

    You’re right, get_search_query() doesn’t work here because the plugin is using a different variable, you can use this instead:

    $search_query = isset( $_POST['swpquery'] ) ? sanitize_text_field( $_POST['swpquery'] ) : '';

    From there you can follow the results template customization guide to output a link to

    $full_results_link = add_query_arg(
        's' => $search_query
    echo '<a href="';
    echo esc_url( $full_results_link );
    echo '">All results</a>';

    and that should do it!

    • This reply was modified 1 year, 7 months ago by  Jonathan Christopher. Reason: Formatting to prevent horizontal scroll
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add link to view all results?’ is closed to new replies.