Search

  • dikkiedutton

    #6265

    Hello

    I’m getting to the end of the build of this site and the search doesn’t seem to be working as it should. By default, whatever the search string, it’s pulling out all the posts and perhaps one page. I want the search to pull out and instance of the word I search for.

    I’m not sure how it’s worked out like that but help is appreciated.

    Cheers

    Dikkie

    ronangelo

    #33859

    The search in the sidebar widget works just fine on my end.

    I tested the word Sensory Garden and 2 post where shown, both containing the word.

    dikkiedutton

    #33860

    And that’s the issue – it’s pulling results from the posts. I want the search results to pull everything the search string results from the posts AND the pages. For instance, if you search for ‘health’ i know that’s on a few of the PAGES in the content. However, it’s pulling out the four posts on the site plus one page. I’m using this as a website as opposed to a blog so the page content is perhaps more important than the posts.

    Mod

    Kenneth John Odle

    #33861

    Have you changed the Graphene settings to display as a regular website, rather than as a blog?

    dikkiedutton

    #33862

    In so much as setting a static home and posts page?

    dikkiedutton

    #33863

    I’ve installed the Relevanssi plugin and that seems to be working better. If anyone has any better ideas without using a plugin – gratefully received.

    Mod

    Kenneth John Odle

    #33864
    Quote:
    In so much as setting a static home and posts page?

    No. On the Graphene options page, there is “Options Presets” which will allow you to use Graphene as a normal website:

    pFNKN.png

    I’m not quite sure what these settings do (Syahir?), but it’s worth playing around with, which is what I just haven’t had the time for. Let us know how it goes.

    dikkiedutton

    #33865

    Ahh, just changed it to that and that’s taken me back a few steps… bugger! Let’s hope it does something nice behind the scenes.

    Thanks anyway – appreciate it (in some weird kind of ‘got to redo bits to the website’!)

    Cheers

    Dikkie

    dikkiedutton

    #33866

    OK, so now I have it looking reasonable again… the search is working better and pulling out content on the pages – however it seems to be still putting the posts at the top of the results – when, in this instance, the page content is more important. Is there a way of prioritising the page content?

    Cheers

    Dikkie

    dikkiedutton

    #33867

    So i’ve found a solution that searches only pages, again – isn’t ideal. But if anyone knows of getting the pages first then posts last – I’d settle for that!

    Add this to functions.php:

    <?php
    function mySearchFilter($query) {
    $post_type = 'page';
    if($query->is_main_query()){
    if ($query->is_search) {
    $query->set('post_type', $post_type);
    }
    }
    };
    add_action('pre_get_posts','mySearchFilter');
    ?>
Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.