The use of wpdb->insert
and wp_insert_post
both accomplish an SQL Insert, which is why you’re seeing 2 records each time. You must use only one instance of an insert method, and then Pass $my_post
to WP_Query
CLARIFICATION
As Milo points out in his comment wpdb->insert
will insert into any table, while wp_insert_post
is used to insert a post into the wp_posts table. wpdb->insert
is used mainly for custom tables.
In your case:
<?php $wpdb->insert( 'auto_importare', $insData); ?>
Sticking with the premise that $wpdb should be used for custom tables, you would then use wpdb->get_results
to select the data you just inserted:
<?php $post_results -> $wpdb->get_results( 'SELECT make,model, version,description FROM wpdb->auto_importare'); ?>
Lastly, and this part escapes me at the moment, you would build your post query from $post_results
Related Posts:
- the_date() not working
- Transaction when using WP functions rather than vanilla SQL?
- How to get the list of WooCommerce product image of a certain category from database?
- How to make WordPress plugin check for database changes and then do something?
- Alter query on edit.php
- How to Join two tables from separate databases within WordPress
- Delete post revisions on post publish
- Would manually deleting the dumping data fix a “#1062 – Duplicate entry ‘1’ for key ‘PRIMARY'” phpMyAdmin error?
- How to sort results from a custom database table
- WP database error for comments_popup_link()
- my function doesn’t return my post from today
- register_activation_hook isn’t adding table to DB
- What SQL / WordPress queries would need a nonce?
- Why is variable not working on custom sql query using wpdb?
- Get stock by custom meta field on all Woocommerce variable products
- Create WP_Query to search for posts by their categories or their parent/child categories
- mysql query from wordpress page using custom table
- Importing Geo data into wordpress database
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Long running queries
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- $wpdb->insert() does not Insert record in a table
- WordPress SQL injection
- Use $wpdb or other PHP script method to find/replace in WP database
- How can I add a new row in a separate database when someone registers via WordPress?
- PHP -> SQL Query with Summing
- Pull MySQL data from multiple tables and merge into 1 PHP array
- Use variable in SQL statement
- Why my query does not run with prepare
- making php value numeric
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- WordPress Custom Query: Combining Two Functions
- SQL error with custom query
- Database SQL query error
- Build A Custom SQL Query for WordPress Search
- How to run complex query using PHP
- How can i limit the number of posts to the most recent 6 in my query?
- Inserting other fields to existing registration form in a WordPress theme
- Query doesn’t display text data with apostrophes
- How to do a MySql query in WordPress?
- SQL Query Search page
- How can I display a query in a page?
- can’t delete a row from post_meta table
- Include a custom field in mysql query
- Conditional statement within WP SQL query
- Query Concatenation
- SQL query to retrieve the number of WordPress posts with all given categories
- How to properly prepare a column name if passed to a stored procedure?
- Set WP_query ‘order’ option by another tables value
- WordPress default Search function inconsistent in WooCommerce Product Titles
- How can I save unique user data on my site? [closed]
- Order by summing multiple values
- Update results, Before deleting the related category [closed]
- Sum the total amount of a specific product purchased per user and display in table
- Ordering users by custom user meta
- Increase offset while looping
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?
- Hacked WordPress website /Homepage redirect [closed]
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Replacing mysql_escape_string in a custom plugin when moving to PHP7
- How to pre populate a form field with a link of a current user’s author profile?
- Weird 404 URL Problem – domain name being placed at end of urls
- wp query foreach deleting record returning only first or last item
- Refresh table data with Ajax
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- database sent to a JSON file
- Archive post by meta value + 24hours
- inserting a post from an extern php file but post content doesn’t show on wp site
- Query if audio attachment AND/OR custom field
- Database query works fine outside WordPress
- $wpdb->wp_users returning empty value for
- Genesis framework comments broken?
- Large Woocommerce Site (83,000 items), What Can I Do? [closed]
- Using custom tables for old posts
- register_taxonomy() take much queries
- Databases – Submitting data from inputs to database [closed]
- Help with a $wpdb MySQL Query
- Not connecting to database in file with multiple MySQL connections
- Which is the correct way to conditionally enqueue a CSS file?
- Way to bulk make all my tags lowercase?
- $Wpdb post meta query is not working with mutliple meta keys and values? [closed]
- How i can obtain all the post meta for a specific post as an array?
- Making a query to the DB using same parameters of loop
- multiple where condition in result query
- Odd / Even posts add class minus first post
- Grouping posts by a custom meta value
- unable to use ‘new WP_Query’ in AJAX call
- Multiple meta_key in one global $wpdb;
- Custom array from a query only write the last row of the query
- WordPress member notification
- Is it best to avoid using $wpdb for security issues?
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- Can’t Query Custom Table Using $wpdb Method
- Moving wordpress site from localhost to live server using GoDaddy cPanel
- How does WP work in conjunction with a web server?
- WordPress Block developer from exporting Database via PHP
- How to list commenters and days since last commented
- How to add div blocks after certain set of post