[wp-hackers] Custom Post Type

Austin Matzko if.website at gmail.com
Sun Jan 27 13:30:39 GMT 2008


On Jan 27, 2008 2:35 AM, Dan Larkin <nitephire at gmail.com> wrote:
> I'm looking to write a plug-in which uses the in-place posts table; however,
> I'd like to use the 'post_type' column to insert a type other than 'post' or
> 'page,' such as 'album' or 'group.'  This is desired because it would keep
> these posts out of the Page and Post sections under the admin Manage
> screen.  Ideally though, I'd like them to be treated as regular pages so as
> to take advantage of the existing template system.  The problem I've run
> into is that the &get_post and &get_page functions seem to pretty much
> ignore any records that have a 'post_type' entry that isn't 'post' or
> 'page.'  I'm wondering if there is a hook or other sort of mechanism that I
> can use to make WP handle other values of 'post_type.'

One way you can do this is setting the post_type query variable before
the posts are retrieved, say at the "parse_query" action hook, by
doing something like set_query_var('group') or whatever.

> Also, on a bit of a side-note, how much of a taboo is it to alter existing
> WP table structures?  For instance, to add a column to the comments table?
> Will it break upgrades and the such?

One of the most popular plugins, Mark Jaquith's "Subscribe to
Comments," alters the comments table by adding a "comment_subscribe"
field, and the lead WP developers featured it on the WordPress Extend
page for months, so I would say there is not much of a taboo.


More information about the wp-hackers mailing list