There comes a time when doing a standard query just isn’t enough, you start out with an idea in your head and continue to develop it while looking at the feasibility, as this thought process continues you realise that there is a lot more than meets the eye, this isn’t something that can be done in one line of code, it requires a more intricate solution, and here was mine…
SELECT p.guid, p.post_date, p.post_title, p.post_excerpt, p.post_status, p.post_type, p.post_title, p.ID, rel.object_id, rel.term_taxonomy_id, tax.term_taxonomy_id, tax.term_id, t.name, t.term_id
FROM community.wp_posts p, community.wp_terms t, community.wp_term_relationships rel, community.wp_term_taxonomy tax
WHERE rel.object_id = p.ID
AND rel.term_taxonomy_id = tax.term_taxonomy_id
AND tax.term_id = t.term_id
AND t.name = '$event_category'
LIMIT 6
A 4 table query against the WordPress database pulling out posts with certain tags for use on the Events Pages ”Related Blog Posts” Section. Took me a while to get my head around it, but it worked in the end!



Leave a Reply
Comment Guidelines
Please stay on topic; Spam and irrelevant comments will be deleted, your IP may be banned, and any URLs in your comment will be blacklisted
Some HTML formatting is allowed, such as: <em>italics</em> and <strong>bold</strong>
Comments may be moderated