Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress Custom Table or Custom Post Types?

I am using wordpress to make a site which has job posts, and I want to know the best way to go about storing company details, as each job post must be linked to a company.

Normally I would have just set up a companies table in my database, and put a company ID within each job post, then joined to get company details.

However I have often come across the idea that it's not always the best option in Wordpress development to create new tables (such as here). Instead I would be better using custom post types.

But how would this work to store company details? Would it be right to create a custom post type for companies, and then add a new post for each company? And then use custom fields to store data about each?

Or would I be best off creating new database tables? What is better and why?

like image 989
gray Avatar asked Oct 23 '13 16:10

gray


1 Answers

I suppose it is the best to use custom post types with post meta in conjuction with meta boxes. This way, you will be able to manage in ease your companies, and yet, you will be able to operate custom queries on companies via the WP_Query class.

Currently I am building a business directory for a my client, so I decide to use the custom post types because of flexibility. Also I made a custom script for managing company information in conjuction with post meta.

Take a look in the screen shot to undestraint what I mean :

enter image description here

Note that whenever I like to add new data to companies, I am free to just add some extra meta boxes, and then save the extra data as meta data for the post. This way is matter of minutes to extend a standart data entity.

What you need:

http://codex.wordpress.org/Post_Types http://codex.wordpress.org/Function_Reference/add_meta_box http://codex.wordpress.org/Function_Reference/register_taxonomy (optionaly) http://codex.wordpress.org/Function_Reference/get_post_meta http://codex.wordpress.org/Function_Reference/add_post_meta

I hope you this will help you :)

like image 95
KodeFor.Me Avatar answered Sep 30 '22 18:09

KodeFor.Me