Understanding WordPress Taxonomy Table Relationships

When working with taxonomies in WordPress, it’s helpful to understand the taxonomy database schema. The WordPress database contains three tables for storing taxonomy data:

  • wp_terms – stores all of your taxonomy terms
  • wp_term_taxonomy – defines what taxonomy each term belongs to
  • wp_term_relationships – cross-reference table that joins taxonomy terms with your content

Let’s look at an example database query joining the taxonomy tables. The below query will return all posts with all taxonomy terms assigned to each post:

SELECT wt.name, p.post_title, p.post_date 
FROM wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id
INNER JOIN wp_term_relationships wtr ON wtt.term_taxonomy_id = wtr.term_taxonomy_id
INNER JOIN wp_posts p ON wtr.object_id = p.ID
WHERE p.post_type = 'post'

Using joins you can start to understand the relationship between the three taxonomy tables. I’m a visual person, so I created the below graphic to illustrate the taxonomy table relationships.

987247c07f002

Taxonomies are an extremely powerful component of WordPress. Understanding the taxonomy database schema can be very helpful when building more complex WordPress websites. If you are interested in learning more about taxonomies in WordPress, check out my Professional WordPress book.

Professional WordPress Third Edition is Coming!

That’s right, the highest rated WordPress development book on the market is back with an all new third edition! The writing has begun and Professional WordPress 3E has officially passed the halfway mark. Just like the previous edition, this version will be written by David Damstra and myself.

Professional WordPress 3E will be fully updated for WordPress 4.1. The new edition will feature two completely new chapters:

  • Migrating to WordPress – Covers understanding the migration process, generating data mapping guides, and utilizing WP-CLI with migration scripts.
  • Application Framework – Covers using WordPress as an application framework, integrating APIs, external libraries, and web services. Will also touch on native app development on iOS and Android.

As an extra special bonus, we have THE Lisa Sabin-Wilson on board as the Technical Editor for this edition! Lisa is the For Dummies brand franchise author on all things WordPress. She has been working with WordPress since 2003 and writing about WordPress since 2006. Lisa is an amazing asset to have on Professional WordPress and will help make this edition the best one yet!

The book is targeting an end of year release. You can follow our progress and any Professional WordPress Third Edition news with the hash tag #prowp3.

WordSesh 2 Is Live Right Now

WordPress Online ConferenceHave you heard of WordSesh? The online streaming WordPress conference (which is totally free) is currently streaming live right now for WordSesh 2!

WordSesh has two tracks with 58 amazing speakers:

Don’t miss out enjoying this event live. The sessions are recorded, so you could watch them later, but joining in on the chat room and tweet conversations make WordSesh a very special event.

Gobble Gobble

Gobble Gobble!

Writing Secure WordPress Code

A few weeks ago I gave a presentation at WordCamp Europe on writing secure WordPress code. The methods I described in my presentation are extremely important when writing code for WordPress. Whether you are a theme designer or a hardcore plugin developer, you should follow all of these security measures to verify your code is as secure as possible. My presentation slides are below:

WordCamp Europe Is Next Week!

Next week I will be attending and speaking at the first ever WordCamp Europe! The event takes place October 5th-7th in Leiden, Netherlands. WordCamp Europe is going to be an amazing event with a insane amount of awesome presentations.

WordCamp Europe 2013 SpeakerI will be presenting on Writing Secure WordPress Code. I’m scheduled to be the last presentation on Saturday at 17:15. I’ll be covering tips and functions available in WordPress that can help you keep your code as secure as possible. Whether you’re a plugin developer or build themes, it’s extremely important to understand how to secure your code from hacks and exploits.

As awesome as this event is going to be, I’m just as excited to see many of my friends at the event. The Attendees list is a who’s who of WordPress awesomeness. I have so many European friends in the WordPress community that will be in attendance so I can’t wait to hang out!

If you’re attending WordCamp Europe make sure you track me down and say hi!

Free WordPress Security Webinar Today

I'll be hosting a free WordPress Security Webinar Thursday, September 26th at 4pm EDT. The webinar was organized by SiteGround and is available free for anyone to attend. I'll be hosting the webinar with my WebDevStudios Co-Founder Brian … [Continue reading]

Is This Thing On?

I've been pretty bad at blogging lately, but I'm really working to change that. Stay tuned! … [Continue reading]

Grub Soda

grape_three_olives_vodka

One of my favorite drinks lately has been what I call: Grub Soda. It's a delicious, refreshing, and low-calorie drink for any occasion. If you'd like to try it follow the instructions below. Ingredients: Club Soda Grape Vodka To make, … [Continue reading]

Do You Want Professional WordPress Plugin Development Second Edition?

pro-wordpress-5-star-reviews

Recently I've been thinking about my book Professional WordPress Plugin Development, and whether there's enough demand for a second edition. Over the years I've received some amazing feedback from readers, many of whom have since released plugins … [Continue reading]