[wp-hackers] pre_get_posts problem
Krusty Ruffle
krustyruffle at rustykruffle.com
Sat Jul 31 17:27:16 UTC 2010
I've been trying to figure this out too. I have not figured out a way to use
the 'request' filter for this. I think the problem is that the conditional
functions cannot work at this point. If you take out if statement then you
can inject the custom post types in there, but it is site-wide and causes
issues on some of the admin pages. I've also looked into the 'parse_request'
action which seems to have the same problems. Looking at the 'query_vars'
filter does no good as the custom post type is already in the
'public_query_vars' array, assuming the post type is 'publicly_queryable'.
The 'pre_get_posts' filter seems hackish but it also seems to work without
problems, assuming you block it from working on admin pages.
Sorry that I do not have an answer for you, but maybe someone with more
understanding can see what's been tried and what we're missing here...
On Sat, Jul 31, 2010 at 2:42 AM, Angelia Baladon
<angelia at 10sexyapples.com>wrote:
> Hi all,
> Well, I'm still at it trying to figure out what to do to get my custom post
> types in the loop for my author.php file. Ironically, I think I'm beginning
> to understand why everyone is using the pre_get_posts solution ... ? I got
> this bit from Andrew ... thanks Andrew! but, unfortunately, I tested it and
> it didn't return any results. Does anyone else have anything to add that
> might help here? There are literally hundreds of sites out there
> recommending the pre_get_posts solution to this, so, it anyone can help
> sort
> this out, I'll be sure to go viral with the answer ... if only *sigh*. It's
> over my head, so, all I can do is keep begging ;-)
>
> Here's the code from Andrew:
>
> <code>
> function my_request_cpt_author( $query_vars ) {
> if ( is_author() )
> $query_vars['post_type'] = array( 'post', 'my_post_type' );
> return $query_vars;
> }
> add_filter( 'request', 'my_request_cpt_author' );
> </code>
>
> It's a whole new month, so, how 'bout it?
>
> Angie
> _______________________________________________
> 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