Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • CTAS with LONG Column for 9i and higher Oracle
  • Good link for LIO in Oracle ( Logical IOs) Oracle
  • Checking SQL Server Version SQL Server
  • create database link syntax Oracle
  • When to rebuld B-tree index Oracle
  • move_arch_files.ksh Linux/Unix
  • Guide to Linux System Command Mastery Linux/Unix
  • fdisk -l explaination about Primary-Logical-Extended Partitions Linux/Unix
  • Good RAC & Standby Notes Oracle
  • tuning commmand for cpu, ip and memory stats Linux/Unix
  • Vivek’s egrep commands to trace problem. (on linux x86-64) Linux/Unix
  • How to check current redo log progress redo_progress.sql Oracle
  • process id based files and processes Linux/Unix
  • currwaitobj.sql SQl_ID and SQL statement you can get from currwaitobj.sql Oracle
  • sql_doing_fts.sql 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

  • My FTP Job Scheduling for www.pvmehta.com PHP/MYSQL/Wordpress
  • upload.html PHP/MYSQL/Wordpress
  • 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
  • Jai Shree Ram PHP/MYSQL/Wordpress
  • For Perl DBI installation and testing program 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)
  • Django (0)
  • GIT (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (394)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (1)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (343)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • tracksqltime.sql05-Mar-2026
  • Complete Git Tutorial for Beginners25-Dec-2025
  • Postgres DB user and OS user.25-Dec-2025
  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • 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

Archives

  • 2026
  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Finding last recovered file on DR and remove all chanracters before any “/” Linux/Unix
  • Single character replacement in Unix Linux/Unix
  • Search and replace editor command in vi Linux/Unix
  • MYSQL and Oracle Comparison for Oracle DBA MYSQL
  • How to find where datafile is created dbf_info.sql Oracle
  • Benefits and Usage of RMAN with Standby Databases Oracle
  • Physical Standby switchover with session active Oracle
  • How to sort list of files on basis of their sizes. Linux/Unix

Copyright © 2026 pvmehta.com.

Powered by PressBook News WordPress theme