I read this thread with interest. What I want to do is somewhat hard to explain and is confounded further by the fact that my pal is using Thesis, which goes about WordPress in a very different way. ~sigh~
Scenario is this:
1) A company profile post exists in profiles category and company name profile without any tag.
2) Regular news updates will be posted to the site that are categorized in a News category and also categorized in the company category. Using tags that match the company name seemed to be the best way to integrate the content.
So we have 3 categories involved. Profile, News, and Company. When visitors choose the profile content, it is a single post that we want to augment with content from the News Category relating to that Company.
If you're still reading and understanding, I totally appreciate you!
I admit that I am not SQL savvy, although I have administered databases in the past. The problem is ... that was over 15 years ago! I would qualify my skill level is being "dangerous" but not foolish.
If worked out the following query which kind of does what I want:
SELECT post_title, post_date, post_content, name AS cat_name
FROM wp_posts p,
wp_terms t,
wp_term_relationships r,
wp_term_taxonomy tt
WHERE p.post_status='publish' AND
tt.taxonomy='post_tag' AND
tt.description=t.name AND
p.id=r.object_id AND
r.term_taxonomy_id=tt.term_taxonomy_id AND
tt.term_id=t.term_id;
The problem is this, I can't figure out how to ask "if" before submitting the query and this query returns content that is unrelated to the company because the conditions are met and there is nothing to exclude non-company related News.
Help me please. This solution is in the critical path.