Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • default permission on ~/.ssh/authorized_keys2 or authorized_keys Linux/Unix
  • rm_backup_arch_file.ksh Linux/Unix
  • v$event_name Oracle
  • DBA_HIST_SQLSTAT contents Oracle
  • chk_space_SID.ksh Linux/Unix
  • Logic to chech # of parameters command line parameters Linux/Unix
  • Sample WW22 listener.ora Oracle
  • Oracle Identifiers Oracle
  • Single character replacement in Unix Linux/Unix
  • remove archfiles only when it is applied to DR rm_archfiles.sh Linux/Unix
  • v$backup.status information Oracle
  • Is It Recommended To Apply Patch Bundles When PSU Is Available? -ID 743554.1 Oracle
  • Passing from Unix to PLSQL using bind variables Linux/Unix
  • replacing ^M character when passing files from Windows to Unix Linux/Unix
  • Goog notes on X$ tables Oracle

PHP code to add WordPress posts in bulk programmatically

Posted on 17-May-202303-Jun-2023 By Admin No Comments on PHP code to add WordPress posts in bulk programmatically
Following code will be used for adding multiple entries to 

<?php


// This is needed to use WP functions. 
require_once('../wp-load.php');

//echo "%%%%". preg_replace("/:/", " ", "21-Dec-2010:10:37:27", 1);

// Category tables are 
// wp_terms here term_id will present category_id, 
// wp_term_relationship show relationships with posts. 
// wp_term_taxonomy-for total post count
// 4= oracle, 10-sqlscripts 

// Read file and disect in different field.
$fh= fopen('UNIX.txt','r');
$lineno = 0;
while ($line = fgets($fh)) 
{

if ( strstr($line, "#################") ) {
//////////////////////// First line of post
      echo "POST#" . "<br>";
      echo "- - - - - - - - - - - - - - - - -  - - - - -  -- - -  - --  - - " ."<br>";
   
      if ($lineno != 0) 
      {
          $new_post = array(
                         'post_title' => $v_title,
                         'post_content' => $v_content,
                         'post_status' => 'publish',
                         'post_date'  => date("Y-m-d h:i:sa", strtotime($v_timeStamp)),
                         'post_category' => array(16,7)
                        );
        $post_id = wp_insert_post( $new_post );
    
        if( $post_id ){
         echo "Post inserted successfully with the post ID of ".$post_id;
        } else {
         echo "Error, post not inserted";
        }
      }

      $lineno = 0;
     // echo "v_content=" . $v_content;
      $v_content="";
  } 
  else   {
//     echo "line number=" . $lineno . "<br>";
         if (strstr($line, "Date >>-->") )
         {
// Extracting time stamp 
             $v_timeStamp= substr($line, 11);
             $v_timeStamp = preg_replace('/:/', ' ', $v_timeStamp, 1);
             echo "v_timestamp = ". $v_timeStamp;
         }
         elseif (strstr($line, "Title >>-->" ) )
         {
// Extract Title
             $v_title= substr($line, 12);
             echo "v_title = ". $v_title;
         }
        else 
        {
// Populate contents by appending them 
            $v_content .=  $line . "<br>";       
        }
      $lineno = $lineno + 1;
  }
}


fclose($fh);



?>
PHP/MYSQL/Wordpress Tags:multiple post using php, php, pvmehta.com, wordpress

Post navigation

Previous Post: DBA_HIST_SQLSTAT contents
Next Post: GSQ.sql

Related Posts

  • How to hide author name in WordPress BLOG PHP/MYSQL/Wordpress
  • Windows based Command line mailing program like mailx (Sednmail for windows) PHP/MYSQL/Wordpress
  • Shuffle an array PHP/MYSQL/Wordpress
  • newupload.html PHP/MYSQL/Wordpress
  • My FTP Job Scheduling for www.pvmehta.com PHP/MYSQL/Wordpress
  • upload.html PHP/MYSQL/Wordpress

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (387)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (336)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024
  • Reading config file from other folder inside class24-Sep-2024
  • Python class import from different folders22-Sep-2024
  • Transfer SQL Profiles from One database to other database.05-Sep-2024
  • Load testing on Oracle 19C RAC with HammerDB18-Jan-2024
  • Add new columns in dataframe30-Sep-2023

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • PLSQL Table Syntax 2 Oracle
  • How to find who is using which Rollback segment and how many rows or blocks in that rollback segments, Oracle
  • How to know Number of CPUs on Sun Box Linux/Unix
  • Giving Grant on v$DATABASE Oracle
  • configUOCIOTTO.ora Oracle
  • Finding Oracle Patches with opatch Oracle
  • find_du.ksh to find # of files, their sizes in current folder and its subdolder Linux/Unix
  • USER_TABLES.Freelists Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme