The last couple of days I’ve been working on a plug-in that adds the functionality of keeping scores from a paintball game. When I manage to finish it I want to present players with a form so they can add in stuff like: hits, deaths, wins, losses, location, role and date.
That goes to a custom table in the WP database.
They will also get a profile page that shows the last 5 records, win/lose ratio’s and the likes.
The admin also has a menu that shows this table, and should be able to manipulate the date (incase of abuse).
I’ve got further with the plugin then I thought. Admin screen is present and loading the info from the table (sorting some columns). But I haven’t yet got the edit or delete functionality to work.
Which got me thinking. I’ve worked with custom post types before. Wont it be easier to make this plug-in in to a custom post type? Can users send data to it from the front-end? Can I query the data and do some simple math with it? Admins can change the data fairly easy with a custom post type if I’m not mistaken.
Only downsides I can think of now is theme problems. I think its easier to show the data from the custom table with a plug-in via short codes then integrate custom-posts in a theme?
Can I create short code’s for the custom post type?
So should I drop the plug-in way and go for a custom post type? I’d like to be able to share this plug-in eventually, so if I go with the custom-type I’ll probably end up making it in to a plug-in that enables the custom-post-type.
The
posts
andpost_meta
tables are made for regular blog posts and similar content. Look at the schema and ask yourself: Do I need these fields?Building a custom form for your custom table is almost the same process as building one for a custom post type. But in your own table you can use just the fields you need, you can even use another DB engine and PDO if you want.
Plus, custom post types donât work across a multi-site network, they might be affected by badly written plugins (some enable their metaboxes or taxonomies for all public post types).
The tables you use should fit your data model, not the other way around.