Separate Database Table Support for Custom Post Types
|Reported by:||rahul286||Owned by:|
|Component:||Posts, Post Types||Keywords:|
While working on custom post types, I felt need for this enhancements.
This can be achieved by adding an extra argument to the register_post_type function like below...
register_post_type( 'acme_product', array( 'labels' => array( 'name' => __( 'Products' ), 'singular_name' => __( 'Product' ) ), 'public' => true, /* Database separation */ 'db_tables' => array( 'prefix' => '', //by default, value of $table_prefix will be used. If user sets this value to something, it will be used as prefix for both of following tables 'base_prefix' => '' , //this will control it tables are to be kept sitewide or per blog 'posts_name' => 'acme', 'postmeta_name' => 'acmemeta', ), );
This small enhancement (not from coding perspective) will help more plugins authors go for custom post type.
Reasons are - first they will get option to have separate data storage.
Second - if some other badly coded plugin manipulates wp_posts table in some wrong way, it won't have sideeffect on third-party data.
Third - Plugin authors will get more space to experiment as at any time they will be dealing with their own plugin's data.
Of course, one of the goal of this nice feature must be to abstract database layer, but as a developer I feel it would be better if I can have some control over database without loosing power of this new (custom post type) feature.
Change History (7)
- Resolution set to wontfix
- Status changed from new to closed
comment:4 @martin.krcho — 9 months ago
- Keywords changed from post type, database to post type database
- Resolution wontfix deleted
- Status changed from closed to reopened