[wp-testers] can't query/get posts of custom post type using category argument

Matt Richmond matt at crowdfavorite.com
Tue Apr 13 20:40:13 UTC 2010


I'm able to get posts in a custom post type of "FAQ" and with a
category name of "bike", as in the code below.

The only real difference I made to your code was to remove the
'post_parent' restriction, and referenced the global $post before my
loop.

	$args = array(
		'post_type' => 'FAQ',
		'category_name' => 'bike',
		'numberposts' => -1,
		'post_status' => null,
		);
	$members = get_posts($args);
	
	global $post;
	foreach ($members as $post) {
		setup_postdata($post);
		the_title();
		echo '<hr />';
	}


> ---------- Forwarded message ----------
> From: Ross Chapman <ross at folkspants.com>
> Date: Mon, Apr 12, 2010 at 5:53 PM
> Subject: [wp-testers] can't query/get posts of custom post type using
> category argument
> To: wp-testers at lists.automattic.com
>
>
> Not working using category_name or category with ID.  Example:
>
> <?php
>
>                        $args = array(
>                                'post_type' => 'team',
>                                'category_name' => 'Executive',
>                                'numberposts' => -1,
>                                'post_status' => null,
>                                'post_parent' => $post->ID
>                                );
>                        $members = get_posts($args);
>                        foreach($members as $post) :
>                        setup_postdata($post);
>
>                        ?>
>
> Thanks,
> -Ross
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
>


More information about the wp-testers mailing list