Support » Plugin: Search Exclude » Not Hiding A Page – Simple Implementation

  • Resolved luboslives

    (@luboslives)


    Hi there,

    I have a site-wide search form only on our 404 page – nothing special going on, I’m just using get_search_form();

    I’ve looked through my template and I have no other search filtering going on besides

    if ('woocasepro' === $post->post_type) {
        do_action('searchexclude_hide_from_search', array($post->ID), true);
    }

    (To hide product banners)

    I’ve tried sticking do_action('searchexclude_hide_from_search', [27991], true); into that same function, for this specific page ID, but no luck.

    See https://cdnrecords.com/?s=existential+dissipation

    Edit – could it have anything to do with WP5 and the new block editor?

    • This topic was modified 2 years, 3 months ago by luboslives. Reason: Added question about WP5

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author pronskiy

    (@pronskiy)

    Hey there!

    Not sure if I got you, let me clarify. So you have a search page here https://cdnrecords.com/?s=
    And you want the search results to not show “Existential Dissipation” items.
    So to do that you need to either mark all those items as excluded explicitly. Either from WordPress admin with checkbox, or by passing all IDs as an array to the action.
    Or the better way would be to exclude by post type. I believe in your case it’s ‘product’ or ‘bundle’ maybe. And for that it’s better to use filter, something like:

    
    add_filter('searchexclude_filter_search', 'filterForProducts', 10, 2);
    function filterForProducts($exclude, $query)
    {
        return $exclude && 'product' === $query->get('post_type');
    }
    

    Please let me know if this helped you?

    Thread Starter luboslives

    (@luboslives)

    Sorry, no I simply meant that I am trying to hide the Existential Dissipation page from search results – using the plugin as it is intended. And it’s not working for some reason.

    Maybe I need to specify a lower priority inside add_filter() ?

    Plugin Author pronskiy

    (@pronskiy)

    Ah, okay, I see. So you don’t need an action for that, just check the corresponding checkbox on that page at admin. And that should work.
    If not, then it’s probably some conflict with other plugins or your theme.
    You may try increasing priority at plugin itself, file wp-content/plugins/search-exclude/search-exclude.php find line and add priority as an additional argument:

    
    add_filter('pre_get_posts', array($this, 'searchFilter'));
    

    Although, I don’t think that’s gonna help you. Please contact me by email for assistance: roman@pronskiy.com

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Not Hiding A Page – Simple Implementation’ is closed to new replies.