2014-02-06 4 views
0

나는 현재 자신의 WordPress plugin을 제작하고 있습니다 .Plugin이 활성화되면 자동으로 word press에 추가 될 새 페이지 (또는 게시물)를 만들어야합니다. 그리고이 플러그인이 비활성화 될 때 제거됩니다. 페이지의 내용은 플러그인에서 입력하는 내용입니다. 어떻게 할 수 있습니까?wordpress에 페이지 추가

답변

0

당신은 페이지를 생성하는 기능을 wp_insert_post 사용하거나 게시물이 http://codex.wordpress.org/Function_Reference/wp_insert_post

예를 확인할 수 있습니다.

// Create post object 
$my_post = array(
    'post_title' => 'My post', 
    'post_content' => 'This is my post.', 
    'post_status' => 'publish', 
    'post_author' => 1, 
    'post_category' => array(8,39) 
); 

// Insert the post into the database 
$post_id = wp_insert_post($my_post); 

당신은 $ post_id를 withing에의 add_post_meta 또는 update_post_meta를 사용하거나 설치하고 페이지를 제거 post_meta varible를 사용할 수 있습니다.

0

같은 것 this? 페이지 생성을 다루기 위해 링크 된 포스트에서 참조 된 코드가 있습니다. codex도 있습니다.

관련 문제