WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Importer
Automating POST and import to WordPress Importer (2 posts)

  1. Kolokial
    Member
    Posted 1 year ago #

    I'd like to try and setup a an automated .xml import, using the WordPress Importer.

    Basically, I want to submit an .xml file at the click of a button from either the wp-content/themes/theme-folder/ or an external source to wp-admin/admin.php?import=wordpress and run it through the WordPress Importer to import the data.

    This has proven difficult so far. Is it even possible to POST a file from the server to the server again?

    I've searched through the wp-admin folder and files relevant to imports, and the wordpress-importer.php plugin to see if I can bypass the upload part of the process, and maybe use a class to initiate an import, but everything i've read and seen suggests the import is dependent on the upload.

    Here's what I've been trying though.

    Reading the .xml file into the parse class. The .xml file outputs if I put it into $output, and the if($importing->parse($xml)) returns true, but no information appears in WordPress or the database.

    require_once ABSPATH.'wp-content/plugins/wordpress-importer/parsers.php';
    function get_sample_data(){
     $output = '';
     $importing = new WXR_Parser();
     if(isset($_GET['get_sample_data'])){
      if($_GET['get_sample_data']){
       $xml = get_data('xml');
       $output .= $xml;
       if($importing->parse($xml)){
        $output .= "Parsing passed";
       };
      }
     return $output;
     }
    }

    http://wordpress.org/extend/plugins/wordpress-importer/

    [No bumping. If it's that urgent, consider hiring someone.]

  2. WebTechGlobal
    Member
    Posted 11 months ago #

    The best way to perform any automation when it comes to auto-blogging is to import ALL data to a stand-alone database table. One created per .xml or .csv file.

    Then from there we work with the data. Using that database table to track what data has been used. Updating the data and then applying it to posts when ready.

    May sound like opinion. But all approaches have been tried and tested in Easy CSV Importer over the last couple of years and the benefits of getting the data into the database as a first step are great. Better control and avoidance of running into issues once the auto-blogging begins.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic