[wp-hackers] Excluding pages/posts from search

Paul Menard paul at codehooligans.com
Wed Nov 21 03:46:02 GMT 2007


Have been following this thread and thought I would provide some  
comments. On the client non-blog systems I've put together with  
WordPress many have for example home page 'slot' content items that  
were piped to by a WP Page. I run into similar needs where I really  
didn't want that 'slot' content represented as a real Page from a  
search. Some hacking to the template usually solve the issue. Or  
better putting the 'slot' content into post_meta fields: slot1, slot2.  
etc.

If we are tossing in ideas for WP changes I would like to see the  
possibility of a new content type (Not a Post or a Page) that can be  
used for the instance like the Thank You page example given by Alex.  
Using Attachments are difficult since thy have to be tied to a parent.  
Seems kludgy to me, anyway.

Alternatively, I have put together a plugin that may work for your  
needs. It's not automatic or default.  I use on my client site to  
exclude categories from various actions: is_front, is_search, etc.  
This also works for Pages though only for the is_search action.

You are welcome to try this. I've just test with WP 2.3.1 and seems to  
work. I need to spent some time on it for an official Plugin release.  
Find the plugin here: http://www.codehooligans.com/2007/11/20/simply-exclude-plugin/

The admin interface is probably all wrong. Meaning I collected the  
Categories and Pages into a listing under a plugin admin section. Just  
thiking more about this the better solution for Pages would be a  
checkbox in the sidebar on the Page editor screen. If checked will  
exclude the page from search. Pretty simple logic. Again this works  
for Categories and Pages. Have not entertained using it for Tags. hmm.

I for one don't see the need to add a column to the wp_posts table.  
This screams post_meta if anything. And don't really see this as  
something needed in core. I mean core WP does not even include Pages  
for Searches (at least last time I checked). So why would a Page  
Search exclusion be adding into core.

My thoughts anyway. I know I'm not a big player in the WordPres  
development realm but I do work in WordPress almost exclusively for  
small client sites, mostly non-blogs. So there.

Paul Menard
http://www.codehooligans.com





On Nov 20, 2007, at 6:03 PM, Alex King wrote:

> This is sometimes the case, but there are also situations where you  
> simply have a page you don't want searchable or to show up in the  
> navigation list.
>
> Disclaimer: the following is just an example, please try to focus on  
> the larger concept rather than picking apart the example. :)
>
> If you have a contact form on a page, you might want to redirect the  
> user to a different "thank you" page after they submit the form.  
> This "thank you" page only makes sense as a response to the form  
> submission from the contact page, and you would want to exclude it  
> from searches, navigation menus, sitemaps, etc.
>
> What I'm proposing is a standard way for all of these features and  
> functions (and plugins, like the sitemaps plugin) to know to exclude  
> this page by default.
>
> Cheers,
> --Alex
>
> Personal   http://alexking.org
> Business   http://crowdfavorite.com
> Schedule   http://alex.myfreebusy.com
>
>
>
>
> On Nov 20, 2007, at 2:46 PM, Dougal Campbell wrote:
>
>> I just had a couple of thoughts on this. What you're looking for is  
>> some
>> place to store extra snippets of content, associated with an existing
>> page or post, which is not going to be seen by the normal content
>> rendering or the search function. Using actual pages or posts is
>> bothersome because you then have to filter those out from the other
>> convenience functions that are useful for building the site.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list