Programmatically adding Wordpress post with attachment
https://stackoverflow.com/questions/3805603/programmatically-adding-wordpress-post-with-attachment
<?php
require_once("wp-config.php");
$user_ID; //getting it from my function
$post_title = $_REQUEST['post_title'];
$post_content = $_REQUEST['post_content'];
$post_cat_id = $_REQUEST['post_cat_id']; //category ID of the post
$filename = $_FILES['image']['name'];
//I got this all in a array
$postarr = array(
'post_status' => 'publish',
'post_type' => 'post',
'post_title' => $post_title,
'post_content' => $post_content,
'post_author' => $user_ID,
'post_category' => array($category)
);
$post_id = wp_insert_post($postarr);
?>2 Answers
PreviousLàm chức năng up image ảnh cho sản phẩm vào đơn hàng, đặt hàng order demoart.net5s.vn (ok)NextTính năng cho một trang website bán hàng?
Last updated