I'm having trouble trying to think out this SQL select I need to write; here's the gist: I'm programmatically creating posts by importing an excel file, so I'm in 100% sure of post titles, etc, since I'm creating those that aren't found. I've got a few bits of data that I'm using for a lookup of a post before I create a new post: the post_title, that it is a post_type of 'team', and looking up it's term name in a 'term_type' taxonomy (ie 'College').

Here's the $args for a normal simplified taxonomy wp_query lookup:

$args = array('post_type'=>'team', 'post_title'=>$teamName, 'post_status'=>'publish', 'team_type'=>$type);

The trouble is of course that you can't do a lookup in this way with a post_title. Now I could create the select for that but I'm having trouble with the lookup of the joins -- the name in the terms, and with that the term_id to term_taxonomy_id in term_relationships giving me the object_id... I'm sure it's just lack of sleep.

I'll probably just do a simple 'get_term_by' before I try my copy of the query that failed with a post_title lookup in addition, but my geek need to do it all in one go is pushing me to know the 'correct' way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.