Custom search

  • dikkiedutton

    #6206

    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

    Prasanna SP

    #33663

    Try this,

    .search .entry-content .excerpt-thumb img, .search .child-page .excerpt-thumb img {
    display: none;
    }

    dikkiedutton

    #33664

    Thanks, Prasanna. Worked a treat.

    What would I need to add to remove the category from the search result too?

    Cheers

    Dikkie

    dikkiedutton

    #33665

    Think I have it, actually:

    .post-meta p, .post-meta ul, .post-meta li {
    display: none;
    }

    Prasanna SP

    #33666
    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?

    dikkiedutton

    #33667

    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.

    Prasanna SP

    #33668

    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.

    dikkiedutton

    #33669

    Will do, thanks again.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.