Custom search
-
Hi all
I’d like to have my search return without the featured image as a thumbnail, as I’m using the featured image for custom headers on different pages.
So it would be the page title then an excerpt.
Site here: http://c4780711.myzen.co.uk/
No doubt it’s a php function change but I’m not that versed with php yet!
Cheers
Dikkie
Try this,
.search .entry-content .excerpt-thumb img, .search .child-page .excerpt-thumb img {
display: none;
}Thanks, Prasanna. Worked a treat.
What would I need to add to remove the category from the search result too?
Cheers
Dikkie
Think I have it, actually:
.post-meta p, .post-meta ul, .post-meta li {
display: none;
}Quote:What would I need to add to remove the category from the search result too?Do you want to exclude categories from being searched?? Or prevent it from being displayed?
I’m assigning categories to pages anyway in the interests of getting specific pages on the homepage slider (no doubt you’ll tell me that can be done another way!). So what I’m saying is hopefully the search should pull up what people are after anyway, without searching the categories.
Give it a shot, (child-theme functions.php, between
<?php
and?>
)function exclude_cat_from_search($query) {
if ($query->is_search) {
$query->set('cat','-1,-2,-3,-4');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_cat_from_search');Where -1,-2,-3,-4 are the categories to be excluded on search. Replace it with actual category IDs.
Will do, thanks again.
Viewing 8 posts - 1 through 8 (of 8 total)
- You must be logged in to reply to this topic.