- This topic has 1 ข้อความตอบกลับ, 2 เสียง, and was last updated 7 months, 2 weeks มาแล้ว by .
กำลังดู 1 ความเห็น
กำลังดู 1 ความเห็น
- คุณต้องเข้าสู่ระบบเพื่อตอบกลับกระทู้นี้
หน้าแรก › ฟอรั่ม › ถามปัญหาการทำเว็บด้วยเวิร์ดเพรส › ขอคำแนะนำการใช้ฟังชั่น wp_insert_post ครับ
คือมีโพสต์บางรายการที่ต้องเอาลงอัตโนมัติ จึงจำเป็นต้องใช้ฟังชั่น wp_insert_post ครับ
$egp = array(
‘post_title’ => $itemtitle,
‘post_content’ => $itemcontent,
‘post_author’ => 1,
‘post_status’ => ‘publish’,
‘post_category’ => array($cat)
);
$id_egp = wp_insert_post($egp);
if (!$id_egp) {
echo “WARNING: Failed to insert post into WordPress\n”;
}
มันจะได้ WARNING ตลอดเลยครับ พอจะมีคำแนะนำไหมครับ
ดูจากโค้ดยังไม่ครบหรือป่าวครับ
เช่น ตัวแปร $itemtitle , $itemcontent , $cat , $egp
ยังไม่มีที่มาว่าดึงค่ามาจากไหนเลยนะครับ