• Resolved hank3rd

    (@hank3rd)


    I am looking to exclude certain pages from the search results. I know that the suppression is really for posts and categories, but pages do not have categories.

    I was able to use the ID to exclude a page, but I would have to look up many and would have to add any new pages in the future. I wonder if there is another way to accomplish what I need?

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

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

    (@wpdreams)

    Hi,

    Well, probably the best and easiest way to get around this is by enabling categories for pages. After that the category exclusions will be applied for pages too.

    To do that, you can either use a custom code:

    // Add the category taxonomy to the page object type
    function add_categories_to_pages() {
      register_taxonomy_for_object_type('category', 'page');
    }
    
    // Display categories for pages in WordPress admin
    add_action( 'init', 'add_categories_to_pages' );

    ..or maybe even this plugin.

    For the custom code, please check the safe coding guidelines. I would recommend using the custom code, as it leaves less overhead for this one specific task.

    All the best,
    Ernest

    Thread Starter hank3rd

    (@hank3rd)

    I ended up using the code and it works great. Thank you!

    Plugin Author wpdreams

    (@wpdreams)

    Sounds great 🙂

    I will mark this topic as resolved then. Feel free to rate the plugin if you like it, it is greatly appreciated!

    All the best,
    Ernest

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Excluding Pages’ is closed to new replies.