Save custom post type in different table

I need to store custom post type post data into a custom table, not in wp_posts and wp_postmeta. Is it possible? anyone help please. Actually, I have created two custom post type named “truck” and “drivers”. Then I have created a menu page in wordpress admin. Clicking this menu should list all drivers related to truck. There should be also drag and drop system of this interface so that I can assign any truck to any driver. After sorting, it should update table. So I need a new table for custom post type. see my screenshot

2 Answers
2

While I am a big fan of tweaking wordpress as much as it could because it allows us to, I think the best way forward is to have the best algorithm before coding.

Reading your question, I came across ” Actually, I have created two custom post type named 'truck' and 'drivers' “.

Issue: Linking two post types requires extra work as you are doing because natively it is not what WordPress does.

Suggested Solution: Do it, the way WP works naturally: Link a Custom Post Type to a taxonomy. So, instead of having ‘truck’ and ‘drivers’ as CPTs, have ‘drivers’ as CPT and ‘trucks’ as taxonomy! That saves you tons of work, and especially the risk of running into issues should WP Update.

You can then create the custom functionality of dragging and dropping on CPT and taxonomy

Leave a Comment