1383 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Serbia
wpCanyonThemes says

You know, custom post type, custom taxonomy, inability to query multiple terms… Is this fixed yet or not?

And what’s the best way to do it if it’s not?

2441 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
digitalimpact says

afaik it’ll be fixed in 3.1

1383 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Serbia
wpCanyonThemes says

Custom SQL then. :)

415 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 5-6 years
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
unisphere says

Hey, since I had that same problem a few months back I came up with a not so elegant solution, but hey, it works. Here’s an example of how I’m doing it in my latest theme for querying portfolio posts in the terms (categories) the user chooses to display:

// Term IDs you want to query
$portfolio_terms_ids = '1,2,3';

// This will get an array of posts belonging to the terms you defined in the 'portfolio_terms_ids' variable
// 'portfolio_category' is the taxonomy registered for the 'portfolio' custom post type
$portfolio_posts_to_query = get_objects_in_term( explode( ",", $portfolio_terms_ids ), 'portfolio_category');

// Since there currently isn't any way of querying custom terms, use the 'post__in' filter
$wp_query = new WP_Query( array( 'post_type' => 'portfolio', 'post__in' => $portfolio_posts_to_query) ); 

Hope this helps

1383 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Serbia
wpCanyonThemes says

@unisphere – Dude, i love you :) Certainly better then 3 miles long SQL query :) Thank you.

Just 2 things i would like to mention. First one is use $wp_query only on homepage and the second one is don’t name your post types like something the user might put up as name of a page (i am not sure if this issue is still there, but i know when 3.0 came out there was a conflict and the page with the same name as a post type would return as 404).

Thanks again :)

415 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 5-6 years
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
unisphere says

@unisphere – Dude, i love you :) Certainly better then 3 miles long SQL query :) Thank you.

Just 2 things i would like to mention. First one is use $wp_query only on homepage and the second one is don’t name your post types like something the user might put up as name of a page (i am not sure if this issue is still there, but i know when 3.0 came out there was a conflict and the page with the same name as a post type would return as 404).

Thanks again :)

Tell me about it, I learned that the worst way possible and indeed it gives 404 errors so I had to revert back to not using “pretty” slugs for that custom post type, although I’m fixing things in the next update. Regarding the wp_query only on home page, could you talk a bit more about it? I’ve never run into problems using it in other templates.

Cheers

2566 posts Put a Donk On It
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • United Kingdom
  • Exclusive Author
  • Attended a Community Meetup
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Referred between 200 and 499 users
+5 more
ThemeProvince says

I created a function called the_taxonomy that WordPress desperately needs to implement. You can view it here -> http://forrst.com/posts/WordPress_the_taxonomy_Displays_taxonomy_cat-1yx

It basically is the_category(); but for retrieving terms or this instance categories.

1383 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Serbia
wpCanyonThemes says


@unisphere – Dude, i love you :) Certainly better then 3 miles long SQL query :) Thank you.

Just 2 things i would like to mention. First one is use $wp_query only on homepage and the second one is don’t name your post types like something the user might put up as name of a page (i am not sure if this issue is still there, but i know when 3.0 came out there was a conflict and the page with the same name as a post type would return as 404).

Thanks again :)

Tell me about it, I learned that the worst way possible and indeed it gives 404 errors so I had to revert back to not using “pretty” slugs for that custom post type, although I’m fixing things in the next update. Regarding the wp_query only on home page, could you talk a bit more about it? I’ve never run into problems using it in other templates.

Cheers

Well you won’t run into some serious troubles, but wherever you use $wp_query the WordPress will consider it as the homepage and the conditional tags is_home() and is_frontpage() will return true even if it’s not the home (index.php) or frontpage (when you set a page to be the home).

There are probably some more probs, but i ran into that one when creating breadcrumbs (disabling them on homepage, and then it got disabled everywhere i use $wp_query).

415 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 5-6 years
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
unisphere says

@thePhoenix that’s one sexy function dude :)

@wpCanyonThemes didn’t know about that, thanks

1383 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 10 and 49 users
  • Serbia
wpCanyonThemes says

@thePhoenix – Cool :)

@unisphere – You’re welcome :)

by
by
by
by
by
by