Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • When error comes for temporary tablespace with version <= 9i Oracle
  • Jai Shree Ram Oracle
  • Explain Plan Output 2 Oracle
  • scripts to take listener.log backup Linux/Unix
  • plan10g.sql good1 Oracle
  • currwaitobj.sql SQl_ID and SQL statement you can get from currwaitobj.sql Oracle
  • Reclaim temp tablespace for oracle 8, 8i Oracle
  • Find sort details from Db find_sort.sql Oracle
  • How To Transfer Passwords Between Databases (ref note: 199582.1) Oracle
  • how to find VIP from ifconfig Linux/Unix
  • good note for shared pool tunnig Oracle
  • Removing Blank lines from file using grep Linux/Unix
  • kill all processes from specific user in solaris. Linux/Unix
  • sid_wise_sql.sql Further explaination Oracle
  • oradebug ipcrm ipcs 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

  • For Perl DBI installation and testing program PHP/MYSQL/Wordpress
  • Jai Shree Ram PHP/MYSQL/Wordpress
  • How to hide author name in WordPress BLOG PHP/MYSQL/Wordpress
  • My FTP Job Scheduling for www.pvmehta.com PHP/MYSQL/Wordpress
  • Move WordPress site from one hosting service to other. PHP/MYSQL/Wordpress
  • Shuffle an array 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 (388)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (337)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • 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
  • 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

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • Finding locked objects Oracle
  • Implementing Listener Security Oracle
  • shutdown linux Linux/Unix
  • checking connectivity between two servers Linux/Unix
  • login.sql Oracle
  • Kernel Parameters for Solaris Linux/Unix
  • usnsql.sql Displays information about UNDO segments with sql statements Oracle
  • Space padding in korn shell Linux/Unix

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme