Search
-
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
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
Have you changed the Graphene settings to display as a regular website, rather than as a blog?
In so much as setting a static home and posts page?
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
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:
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.
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
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
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.