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
Related Posts:
- Where are wordpress custom types stored?
- Right way to store a large set of similar information on website? [duplicate]
- Should I use custom post types or a custom database tables for plugin development?
- Delete all posts of a custom post type—efficiently
- Order by & include array by specific post ids
- Get list of all registered post types slugs
- Custom Post Types, or completely custom?
- Custom Post Type with Input fields to seperate table on database.
- Right way of storing large number of custom post fields
- How to use custom database tables for custom post types?
- Limit the post for differents custom post type in the same wp_query
- array_pop() expects array, boolean given for $event_type_term ->slug
- Custom Post Type or Custom Tables
- Are custom post types suitable for storing high numbers of data elements, in this case chat messages?
- Custom post type or just use custom fields
- Create Pages from Database
- Use Custom Database with Custom Post Type
- Custom Search | Wrong output & question
- How do I write this SQL statement for Posts written in last 24 hours?
- Save or update data when custom post published
- update a post meta from a single table cell TablePress
- update custom post type meta from a shortcode
- Custom post type Vs. data in own table
- Using posts and postmeta table to store custom Address Book Plugin data
- Automatically adding meta data to posts or multiple query help
- How to use custom post type APIs, but use a different db table
- Developing WordPress on Kubernetes
- Recommended custom post type structure for TV Schedule site?
- WordPress post count not showing for custom post type author
- Where to store custom tagging data associated with a custom post type
- Create a post in custom post type using field in registration form after users submit form
- wpdb custom post_type problem
- Adding custom tables to WordPress
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- Save an array from drop-down in custom meta box
- WP All Import – Using Xpath to set a select value
- Sorting custom post type columns with external data and without meta values
- How to use custom taxonomies to reference complex relationships?
- Create a clone from one WordPress site to another in a few minutes
- How to store multiple values in 1 meta_key with radio input?
- Display a CPT based on a metabox selection
- Database to page routing API?
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- How to handle a CSV with 65,000+ rows and make it searchable?
- How to change wp prefix for custom post type only?
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- Modification of how the data is controlled/showed and stored
- Add update or delete database records using custom post type
- How to import a custom MySQL DB table into a WordPress custom post type
- Display post content with respect to its title?
- Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
- WP_Query orderby and tax_query
- Limit the post for differents custom post type in the same wp_query
- Importing Data from a Non-WordPress database, into WP
- How to organise this data within WordPress
- Organize WordPress site, so it can maintain with huge database
- Save custom post type to external database
- Show data from one Custom Post Type in another Custom Post Type
- Custom Post Types — $args vs. labels array
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Specifying meta field’s column type in Database using add_post_meta
- Add first letter of titles to array, then compare arrays
- Is it a good idea to add a column to the posts table?
- Replace dynamically content in a custom database table when a custom post is created
- Query Custom Post Types with checkboxes
- Running a song lyrics site on WordPress
- Save and user submitted data from a form and display them in the wp backend
- Dump custom post type database
- Create Array from custom post type to display a slider
- Should I use custom taxonomies or not?
- Designing a custom post type with a minimum number of meta fields
- Inefficient Query Confusion
- Querying multiple values from a single key
- Allow front end users to add data to a custom post type
- Check if user has comment on current post
- WordPress hook which triggers on post import
- Update all published posts at once
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- Custom Columns for Custom Post Type Manager
- Entity to store contact form entries?
- How do I disply an array inside a custom post type?
- Custom Post Type Field Array parsing [closed]
- Getting custom post types to properly display alphabetically
- Ideas to connect external database table to wordpress posts as custom field source
- Database alteration: users who voted
- WordPress as a frontend website for iOS app [closed]
- Using custom post types WordPress network
- delete duplicate meta_value with same post_id
- custom post type: own database table structure and custom “new-post” interface
- Import External XML
- Say I have a tech blog, how best would I store technical specs for a phone, if i use custom post types
- How do you make relational post types in WordPress? [duplicate]
- How can I loop at a Specific Taxonomy from a custom post type?
- Update value inside array update_post_meta
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- Custom archive page for custom taxonomy and pagination issue
- Clone wp-admin/users.php (Users Admin Page)
- Get an array of the number of post per year of a custom post type (WordPress)
- Does this archive template part look like its making too many calls to the db?
- Query when is one or several values