Open Search Bar Results in new page

  • Hi,


    I'm trying to implement a search bar on main news page, which is working, however the general news posts are still listed below the search results. Is there a way to open the results in a new page or have the general posts hidden so just the search results show?


    This is my code so far...


    <?php perch_search_form(); ?>


    <?php perch_content_search(perch_get('q'), [

    'template' => 'search-result.html',

    'count'=>9

    ]); ?>


    <div class="row">

    <?php perch_blog_recent_posts(9); ?>

    </div>



    Thanks

  • Hi Clive,


    This is my search form template


    <perch:form id="search" method="get">

    <div>

    <!-- <perch:label for="q">Search</perch:label> -->

    <perch:input type="search" id="q" />

    <perch:input type="submit" value="Go" />

    </div>

    </perch:form>


    Any help much appreicated.


    Thanks

  • Hi Clive, that works great thanks.


    I'm trying to style the search results as per my post listings but have hit a wall with some bits. I can't seem to pull in the post image, post date or control the length of the excerpt. I've managed to get the button and heading to style but can't seem to control the bits mentioned. I've posted the code below, any help/direction is much appreciated.



    Thanks

  • I have only used a variation of the standard Perch Search results template which pulls in URL, Title and Search excerpt using <perch:search> tags. I don't think that the blog post images are available in this context.


    There is a solution discussed here Use The Image In A Blog Post In Search Results

  • Hi Clive, thanks for pointing me to this article. I've managed to implement this but have run into a couple of issues...


    1. I can't seem to change the order of the results - I've tried adding sort order but it doesn't seem to work.

    2. The search returns 23 results, however I've filtered to show 9, but when clicking through to pages 2 and 3, no results are shown.


    I don't suppose you can help?


    Thanks

  • The order of the results is determined by how close they match the search term. If you want to add custom sorting you'd need to do that on the returned array instead.


    How are are you filtering so that you only get 9? The pagination is based on the initial set of returned results from the search function, filter after the function call will not effect the pagination