Creating post from external php file to a specific site of multisite
-
I’ve a wordpress multisite setup in xampp server. I want to post using wp_insert_post() function from a external php page to a specific site of multisite. SO far, I’ve tried the following code, but it creates post to main site, not specific site of multisite.
<?php // Load WordPress require_once("../../../wp-load.php"); require_once ABSPATH . '/wp-admin/includes/taxonomy.php'; $my_post = array( 'post_title' => 'The post title via wp_insert_post Hello World!', 'post_content' => '<h4>Place all your body content for the post in this line.</h4> [wbcr_snippet id="106" url="flebaixgtscj"] ', 'post_status' => 'publish', 'post_author' => $user_id, 'post_category' => array(9), 'post_type' => 'post', // defaults to "post". Can be set to CPTs. 'comment_status' =>'closed' ); // Insert the post into the database $id=wp_insert_post( $my_post ); echo "post id: ".$id."<br>"; ?>
This custom_post.php file is located at the wp theme folder of specific site.
How to do this ? please help.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Creating post from external php file to a specific site of multisite’ is closed to new replies.