[wp-hackers] Custom Post Type

Dan Larkin nitephire at gmail.com
Mon Jan 28 21:24:27 GMT 2008


Well, the filter is just two lines.  The first is the replacement line, now
with str_replace instead of eregi_replace (thanks for the speed tip).  The
second is 'return $where;'.  That's it.  Is there something I'm forgetting?
Again, I'm new to using hooks.

Anyway, I already tried switching the double and single quotes and
eliminating the parentheses within the replacement string just to be sure,
but no luck.

On 1/28/08, Otto <otto at ottodestruct.com> wrote:
>
> What's your filter look like?  Did you return $where ? If you messed
> up the return line, then you'd get all the posts and pages and
> everything back even if the replacement works correctly.
>
> Also, for a simple text replace without regex, you should use
> str_replace. Faster.
>
>
> On Jan 27, 2008 4:45 PM, Dan Larkin <nitephire at gmail.com> wrote:
> > Well, that fixes one problem but creates another.  I created a simple
> test
> > plug-in to run the following code in a function applied by the
> posts_where
> > hook:
> >
> > if ( !is_admin() ) $where = eregi_replace ("post_type = 'page'", "(
> > post_type = 'page' OR post_type = 'group' )", $where);
> >
> > This does make it so that WP will display.  However, I think basically
> it
> > eliminates distinctions.  Under both 'Manage Pages' and 'Manage Posts'
> all
> > records of the posts table are returned.  Any idea why that would
> happen?
> >
> > On 1/27/08, Austin Matzko <if.website at gmail.com> wrote:
> > >
> >
> > > On Jan 27, 2008 4:51 PM, Dan Larkin <nitephire at gmail.com> wrote:
> > > > I do not want these special pages to show up under Manage Pages or
> > > Manage
> > > Posts.  I do want them to show up when one navigates to the pages'
> > > permalinks.
> > > [snip]
> > > > Again, correct me if I'm wrong, but it
> > > > seems like using set_query_var() will return only those posts which
> are
> > > of
> > > > the special value when used in a separate query.  This isn't what I
> want
> > > to
> > > > do at all.  I want the main query that handles usual post and page
> > > display
> > > > to simply get a little extra code functionality to display posts
> with
> > > other
> > > > 'post_type' values.
> > >
> > > So you want posts of both post_type "post" and post_type "group" to be
> > > included together? Then I would use the 'posts_where' filter to call
> > > back a function where a regular expression replaces post_type = 'post'
> > > with (post_type = 'post' OR post_type = 'group').
> > >
> > > To keep the admin area from being affected, just test with
> > > "is_admin()" before applying the filter.
> > > _______________________________________________
> > > wp-hackers mailing list
> > > wp-hackers at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > >
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> 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