`/*.
Plugin Name: Import
Plugin URI: https://veronalabs.com
Description: Import excel data to WordPress
Author: Mostafa Soufi
Version: 1.0
Author URI: https://mostafa-soufi.ir */`
if ( isset( $_GET['do'] ) and $_GET['do'] == 'import' ) { $json = file_get_contents( dirname( FILE ) . '/import.json' );
if ( $json ) { $data = json_decode( $json, true ); // Print your data echo '<pre>' . print_r( $data, 1 ) . '</pre>'; // Each data foreach ( $data as $item ) { // Create post object $args = array( 'post_title' => $item['title'], // your column 'post_content' => $item['content'], // your column 'post_status' => 'publish', 'post_type' => 'post', 'post_author' => 1 ); // Insert the post into the database //$post_id = wp_insert_post( $args ); } } exit;
}
/*
* Plugin Name: Import
* Plugin URI: https://veronalabs.com
* Description: Import excel data to WordPress
* Author: Mostafa Soufi
* Version: 1.0
* Author URI: https://mostafa-soufi.ir
*/
if ( isset( $_GET['do'] ) and $_GET['do'] == 'import' ) {
$json = file_get_contents( dirname( __FILE__ ) . '/import.json' );
if ( $json ) {
$data = json_decode( $json, true );
// Print your data
echo '<pre>' . print_r( $data, 1 ) . '</pre>';
// Each data
foreach ( $data as $item ) {
// Create post object
$args = array(
'post_title' => $item['title'], // your column
'post_content' => $item['content'], // your column
'post_status' => 'publish',
'post_type' => 'post',
'post_author' => 1
);
// Insert the post into the database
//$post_id = wp_insert_post( $args );
}
}
exit;
}