// There’s a confusion in which method you are importing your external table into WordPress. If someway you have parsed you external table data into a PHP variable ex: $data, then it would be simple to import.
foreach( $data as $_dt )
{
$new_id = wp_insert_post( array(
'post_type' => 'vehicle',
'post_status' => 'publish',
'post_title' => $_dt['vehicle_name']
));
if( !is_wp_error($new_id) )
{
update_post_meta($new_id, "stockNumber", $_dt["stockNumber"]);
update_post_meta($new_id, "vin", $_dt["vin"]);
update_post_meta($new_id, "make", $_dt["make"]);
}
}
// Now regarding the data source, if you have already imported your custom table into your WordPress Database, use this simple code to grab the data from it –
$data = $wpdb->get_results("SELECT * FROM $your_table_name");
Related Posts:
- Sql Update CPT from publish to draft and particular custom field
- Populate custom post type/custom fields from an external database
- Query custom fields with three dates – start and end does not work
- How can I query and sort custom-post type using WP_Query
- Meta query and compare “!=” not working as expected
- custom post types, custom fields and normalization
- Custom post type and custom taxonomy key lenght & query performance
- Display Custom Field or Custom Taxonomy in front page /post/product
- How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?
- Orderby if between two meta fields
- How to add dynamic fields on wordpress custom post type page in admin section
- How to access repeater field of a custom field?
- Filter posts by their related field’s custom field
- Post Click Redirect to Custom URL instead of Single Post Page
- wp_insert_post deleting previous post custom meta
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Show posts from WP Custom Post Type selected from a field in a metabox
- Problem in moving cpt’s from local website to live website
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- register_rest_field update_callback don’t work for $_FILES
- Query custom post type and custom field by URL parameters
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Where is get_post_meta value located?
- How to convert Post Object Custom Field into Tags
- How do I query with multiple custom fields orderby in same column?
- PHP Warning with Custom Fields
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- I want to create a metabox under custom taxonomy
- Why is this function so slow?
- meta query multiple values for the same key
- Problem with multi checkboxes value in metabox?
- How can I register multiple custom post fields to json?
- Sort custom post archives by a meta value from a different custom post type?
- filter using custom fields
- Show Post columns to specific users on condition
- Displaying Custom Fields from Custom Post Types [closed]
- Displaying posts inside table having issues
- Custom post types – meta_query: search lesson which starts sooner
- Custom post types & Pages hierarchy – Error 404
- Ordering Post by Meta Key (Not Working)
- Post Filtered by Custom Field Value
- Adding a Section for Visitors
- Error when moving custom post type to bin
- Automatic Set Category For A Custom Post Type
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- How to link custom field of two custom post types?
- How to replicate data storage and querying using WordPress. Custom posts/fields or Custom db tables?
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- Dropwdown: Get taxonomy terms from posts that share preselected terms from 3 other taxonomies
- CPT – Custom Text fields point to new url permalinks
- Autofill advanced custom field with user data
- Confused about where to store my data
- Advanced search form with multiple custom fields
- filter rest api post by a acf filed
- Query posts by multiple custom fields
- How to prepend text to custom field value A, but only if custom field value B matches a certain string?
- Enforce all custom posts have specific custom fields
- Simple Data picker meta box
- How to properly set a value to meta fields of a custom post type in WP-API/node-wpapi REST API?
- sorting in wp query based on custom field value
- Use WP Title instead of custom field to call
- PHP Notice: Unidentified index
- Custom taxonomy template for custom fields loop [closed]
- Meta_Query refuses to return results
- Sort loop by custom field from different post type
- Custom Fields with add_post_meta()
- Run query on specific admin options page and send results to select field in another function
- get_previous_post_link and get_next_post_link of custom post type that share custom field value
- Meta_query by date for Events archive
- Multi Photo Upload with Caption on Front End for Custom Post Type
- Custom post type that lets users create a set of posts?
- Add more custom fields when creating a new custom post type
- Search facility with directories
- check_admin_referer not working in custom meta box for custom post type
- Create Inclusions and exclusions
- How do I display specific custom posts, and how do I edit a post’s singular page?
- WP_posts (Not meta) extra custom field column show and change it in a custom post type
- Post that populates itself (almost) automatically using data from imported excel file
- Fixed custom fields depending on posttype/category
- Automatically assign posts with custom field to taxonomy term
- How do I extract the contents of a CPT’s custom field for all posts?
- What’s the most efficient way to get two queries based on an if statement?
- Attach several custom posts to one meta field
- Custom Field to post_title
- Automatically convert standard posts with custom fields to custom post types
- Custom Fields through plugin in a Custom Post Type
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- How do i create user accounts from custom posts that have email addresses
- Importing URLs of Audio Enclosures
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Multiple domains, Single database, 1 Parent/Master with all content, other domains/slaves with filtered content (based on “location” variable)
- WordPress is giving a warning but my code is working fine
- Error in WP Query. If variable is empty it is displaying previous post value
- WordPress loop, show only one post per custom field
- Query events post type after current date and timezone
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Avoid another meta box in my custom post type
- Show first posts with custom field not empty and order all by title