How to NOT display some pages in search results ?

Hi there,
I have a powerful search option on my site now and it search for keywords everywhere ... Problem is that display pages I don't want to see in the results ... For examples the invoices pages from the membership plugin ...

Is there a way to exclude those from the results ?
Or customize the ones I don't want to appear in the search results ?
Thanks

  • Nastia
    • Support Rock Star

    Hello @Steven, I hope you are well today!

    Any content that has been set to be protected from a membership will not appear in search results.
    Please navigate to Protection Rules ->Pages and modify access for each page as it shown in the attached screenshot.

    Let us know if you require any further assistance!

    Cheers,
    Nastia

  • Steven
    • The Incredible Code Injector

    Thanks Nastia but that doesn't do it !!

    The /ms-invoice/ I'm talking about it not a post or page ....
    *so, it has nothing to do with those rights & permissions, right ?

    Go here : http://v24k.com/?s=gold
    Scroll down, click the "load more" button at the button
    Those are the ones I don't want to appear in the search results
    Thanks for showing me the way

  • Sajid
    • DEV MAN’s Sidekick

    Hi @Steven,

    Hope you are doing good today :slight_smile:

    Yes its custom post type and we have set it to exclude from search results from default search results of WordPress.

    But if you have been using a plugin for enhanced search then it may include the data is in posts table. I suggest you to check the plugin/system settings to exclude the custom post type and set "ms_invoice" to hidden.

    If no setting then look for any action/filter hooks to exclude the custom post type. If you are still not sure then you have to contact the plugin author and get assistance from them.

    Take care and have a nice day :slight_smile:

    Kind Regards,
    Sajid J

  • Steven
    • The Incredible Code Injector

    Hi Sajid,

    I am not using a plugin for the search, it's included within the theme I'm using.

    That said, if those /ms-invoice/ pages are "custom post type" : How come I don't see it in the :
    Membership2 > Protection Rules > Custom Post Types Items ?

    I only have problem with the pages generated by the membership plugin
    You guys are the author, and the reason why I'm requesting assistance.

    Do you mean I should contact theme author to exclude something in the search results ?
    Thanks for confirming

  • Sajid
    • DEV MAN’s Sidekick

    Hi @Steven,

    Hope you are doing good today :slight_smile:

    That said, if those /ms-invoice/ pages are "custom post type" : How come I don't see it in the :

    Because we have excluded it to appear in the admin and in the list. Its only for invoicing purposes in the background.

    Yes, I asked because in case you might have some settings in the administration of this theme to exclude some custom post types like most advanced search plugins have.

    Any way, I have come up with a solution but it requires editing of the plugin files. Go to following address, download "class-ms-model-invoice.php" file and open up with any editor.
    wp-content/plugins/membership/app/model

    Now find following code in this file near ~ line number 325.
    'public' => true,

    And add below code right after the above code.
    'exclude_from_search' => true,

    Save changes and upload the file back to server.

    Note: Don't forget to take backup of the original file first.

    Now search again and let me know if that fixes the issue. If it does then we will make sure the change is added in future version of this plugin so you don't need to make this change every time you update the plugin.

    Take care and have a nice day :slight_smile:

    Kind Regards,
    Sajid J

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.