Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • Good Doc 28-JUN-2006 Oracle
  • To seee semaphores and shared memory segments in Solaris Linux/Unix
  • Goldengate Tutorial Oracle
  • SQL_PLAN.sql for checking real execution plan Oracle
  • Find Multiple levels of object dependencies : depen.sql Oracle
  • Vivek Tuning for Row Locks. Oracle
  • How To Limit The Access To The Database So That Only One User Per Schema Are Connected (One Concurrent User Per Schema) Oracle
  • telnet listening Linux/Unix
  • VIvek Encryption Package and Its Usage Oracle
  • Set Role explaination. Oracle
  • find_cons.sql Oracle
  • Some useful Unix Commands Linux/Unix
  • Getting started with notebook Python/PySpark
  • SQL_PROFILE – I explaination Oracle
  • move_arch_files.ksh /* Good One */ Linux/Unix

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

  • Jai Shree Ram PHP/MYSQL/Wordpress
  • newupload.html PHP/MYSQL/Wordpress
  • Windows based Command line mailing program like mailx (Sednmail for windows) PHP/MYSQL/Wordpress
  • How to hide author name in WordPress BLOG PHP/MYSQL/Wordpress
  • upload.html PHP/MYSQL/Wordpress
  • My FTP Job Scheduling for www.pvmehta.com 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 (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • 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

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • find the files that are 1 day old. Linux/Unix
  • Wait Based Tuning Step by step with SQL statement Oracle
  • Oracle Internal Good Websites 1 Oracle
  • check_copy_progress.sh Linux/Unix
  • useful dg links Oracle
  • find_log_switch.sql Find log switches in graphical manner Oracle
  • Some useful Unix Commands Linux/Unix
  • chk_space_SID.ksh Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme