1383 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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?

2457 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has referred 100+ members
  • Has been a beta tester for an Envato feature
+3 more
digitalimpact says

afaik it’ll be fixed in 3.1

1383 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
wpCanyonThemes says

Custom SQL then. :)

415 posts
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
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
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
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

2580 posts Put a Donk On It
  • Has referred 200+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+10 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
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
unisphere says

@thePhoenix that’s one sexy function dude :)

@wpCanyonThemes didn’t know about that, thanks

1383 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
wpCanyonThemes says

@thePhoenix – Cool :)

@unisphere – You’re welcome :)

by
by
by
by
by
by