programing

WordPress에서 프로그래밍 방식으로 게시물을 만드는 방법

jooyons 2023. 4. 5. 21:33
반응형

WordPress에서 프로그래밍 방식으로 게시물을 만드는 방법

WordPress에서 약 7개의 다른 게시물에 대해 프로그래밍 방식으로 게시물을 작성하는 방법을 알고 싶습니다.

나는 시도했다.

 <div class="demo">     
<?php global $user_ID;
$new_post = array(
'post_title' => 'My New Post',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'post',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post); ?>
</div>

아무것도 표시되지 않았나요?

global $user_ID;
$new_post = array(
'post_title' => 'My New Post',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'post',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);

언급URL : https://stackoverflow.com/questions/14605868/how-to-create-a-post-in-wordpress-programmatically

반응형