Over a million developers have joined DZone.

What's the Meta in WordPress

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

Often when tutorials cover the how of doing a task they do not cover the why. And sometimes you need to understand what problem a feature solves so you can understand where to apply it.

If you have ever looked at the WordPress API or at the WordPress table structure you will find three tables which have the suffix ‘Meta’. What does that mean and what are they used for?

Well the Oxford English dictionary defines the word ‘Meta’ as :-

(Of a creative work) referring to itself or to the conventions of its genre; self-referential:
the enterprise is inherently ‘meta’, since it doesn’t review movies, for example, it reviews the reviewers who review movies

In my career as a codesmith I have always thought of meta in the terms of the word metadata. In other words data about data, and this is exactly what those three tables in WordPress are.

Let me expand on that idea a little.

If you imagine you are writing a simple system for a client and you are using WordPress as a base to write the system. Now WordPress comes with a lot out of the box but your client wants you to store some information about the users of your system, but WordPress, out of the box, does not have fields for them.

You could add an extra table to hold this information but that could lead to issues later on when upgrading WordPress or it could cause problems for your secondary audience if you have coded this system in a non-standard way.

Also it is more code to maintain and that will increase the probability of bugs because I can assure you that under most circumstances your code will not be as well tested as the core WordPress code.

Alternatively you could store data in the UserMeta table. No extra tables, no extra code when you don’t need it, and a standard WordPress approach which will be easier to maintain.


Maybe you are using WordPress as a knowledge base system for a client and you are using the Posts as the Q & A part. You again need to store extra data about the post than what WordPress provides, so it might be worth considering adding new tables. Personally in these circumstances I would use the PostMeta which exists for exactly this purpose.

The same argument applies to CommentMeta in my opinion.

You can access these tables using the appropriate API’s and you can add a visual element using the add_meta_box function, but I will save the detail of how to do this for later posts.

I hope this quick post has got you thinking about how to use meta data in WordPress and your plugin development. If you have more ideas on how you could use the meta tables in WordPress to make a plugin more maintainable then I would love to hear about it.

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


Published at DZone with permission of Chris Odell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}