Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Oracle 11g Training on 29JAN1010 Oracle
  • Running select from V$ views from remote server Linux/Unix
  • Remove DOS CR/LFs (^M) Linux/Unix
  • USE_NL and INDEX hints example Oracle
  • To see mem usage and CPU usage system wide. Linux/Unix
  • Jai Shree Ram Oracle
  • Load testing on Oracle 19C RAC with HammerDB Oracle
  • rm_backup_arch_file.ksh Linux/Unix
  • Caching sequence in Memory Oracle
  • TOP-N Sql to find Nth max or Top N rows Oracle
  • Proc code Oracle
  • sess_server.sql Oracle
  • Another Tuning Article for subheap of shared pool Oracle
  • Building Our Own Namespaces with “Create Context” Oracle
  • find_err.sql for finding errors from dba_errors. 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

  • Move WordPress site from one hosting service to other. PHP/MYSQL/Wordpress
  • Jai Shree Ram PHP/MYSQL/Wordpress
  • Windows based Command line mailing program like mailx (Sednmail for windows) PHP/MYSQL/Wordpress
  • newupload.html PHP/MYSQL/Wordpress
  • How to hide author name in WordPress BLOG 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

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025
  • MYSQL and Oracle Comparison for Oracle DBA24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Python class import from different folders Python/PySpark
  • to see when crontab is changed. Linux/Unix
  • Test Case for Inserting Multiple (2.3 Million rows in 26 Seconds) Oracle
  • eplan9i.sql Oracle
  • Checking SQL Server Version SQL Server
  • PLSQL Table Syntax 2 Oracle
  • TRUNCATE table and disabling referential constraints. Oracle
  • How to find where datafile is created dbf_info.sql Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme