[wp-hackers] Excluding pages/posts from search
Dougal Campbell
dougal at gunters.org
Tue Nov 20 21:46:36 GMT 2007
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.
So where can we stick this content in the existing system?
1) What about using comments?
Comments store additional content snippets, are already associated with
a page or post, and are not searched by the default WordPress search
function.
All you really need is to hook something into the backend admin
interface that lets you add comments to a page or post.
The downside is that if you actually need *real* comments in the same
place that you're using this technique, you're screwed. Unless you do
something funky to filter out your "special" content comments. But that
shouldn't be as bad as trying to filter pages or posts. Using a custom
comment_moderation setting would probably do the trick?
2) How about attachments? I have to admit, I haven't looked very closely
at the attachment stuff, but AFAIK that should work. I believe that
attachment info is not exposed unless you include specific template tags
for it, and I don't think that they are hit in searches, either?
Again, you'll have to fiddle with the backend to provide a convenient
interface, but I think it's a promising idea.
--
Dougal Campbell <dougal at gunters.org <mailto:dougal at gunters.org>>
http://dougal.gunters.org/ <http://dougal.gunters.org>
Alex King wrote:
> [...]
> At Crowd Favorite, we need to do this fairly often for our clients.
> When using WP as a CMS, we will generally use pages/posts for certain
> portions of pages - say sidebar or footer content for a specific
> page/section that the client still wants to be able to edit through
> the web interface (with all the standard formatting applied).
More information about the wp-hackers
mailing list