Create Post Automatically

This will create a Post using PHP.

<pre class="wp-block-syntaxhighlighter-code"><?php
     Code SOURCE:
      <blockquote class="wp-embedded-content" data-secret="HobdKZDRPY"><a href="">wp_insert_post()</a></blockquote><iframe title="&#8220;wp_insert_post()&#8221; &#8212; WordPress Developer Resources" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);" src="" data-secret="HobdKZDRPY" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>	
//set timezone

//require native WordPress function

// Post variables
	$userID = get_current_user_id();
	$leadTitle='Operation Test Post'
	$leadContent='Hello there.  this is the post!';
     //ID# automatically assigned to categories.  For multiple
     // categories, separate with a comma
//Time variables - Sets time for now so post can be published without delay
	$timeStamp = date_create();
	$postdate = date("Y-m-d H:i:s", $timeStamp);	

//wordpress Array and Variables for posting
	$new_post = array(
//THIS submits the array data to creat the new post
	$post_id = wp_insert_post($new_post);

//Error Checking
     if ($post_id){
          echo "SUCCESS!";
     } else {
          echo 'OOPS!  something failed, please try again!';

0 thoughts on “Create Post Automatically

  1. xogqqigr says:

    Your comment is awaiting moderation.

    Order original cabergoline, buy cabergoline cheap us

    Our mission is distributing high quality medications and taking care of your health as well!

    Cabergoline – CLICK TO CONTINUE

    We always do our best to satisfy our customers!

    McKenna May, a Ohio girl who has spent most her life cabergoline battling cancer, will get to visit Disney World after family members raised funds for her to take the trip. For the first time, the government has declared all 50 states a major disaster for the same event. Some pastors plan to hold Easter services cabergoline despite stay-at-home guidance. The donations from Google CEOSundar Pichai and are going to GiveDirectly, a charity which provides cash to needy familiesin the San Francisco Bay area. For the first time, the nations highest court will open a live audio feed as it hears arguments in 10 sets of cases. Read full story for latest details. Order cabergoline guideline.

Leave a Reply

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