반응형
WordPress에서 자동으로 페이지 생성
WordPress 페이지를 자동으로 만드는 방법(예를 들어 플러그인이 활성화되어 있는 경우)?
사용하다wp_insert_post()
페이지를 삽입할 수도 있습니다.http://codex.wordpress.org/Function_Reference/wp_insert_post
아래의 post_type을 참조하십시오.
$post = array(
'ID' => [ <post id> ] //Are you updating an existing post?
'menu_order' => [ <order> ] //If new post is a page, sets the order should it appear in the tabs.
'page_template' => [ <template file> ] //Sets the template for the page.
'comment_status' => [ 'closed' | 'open' ] // 'closed' means no comments.
'ping_status' => [ ? ] //Ping status?
'pinged' => [ ? ] //?
'post_author' => [ <user ID> ] //The user ID number of the author.
'post_category' => [ array(<category id>, <...>) ] //Add some categories.
'post_content' => [ <the text of the post> ] //The full text of the post.
'post_date' => [ Y-m-d H:i:s ] //The time post was made.
'post_date_gmt' => [ Y-m-d H:i:s ] //The time post was made, in GMT.
'post_excerpt' => [ <an excerpt> ] //For all your post excerpt needs.
'post_name' => [ <the name> ] // The name (slug) for your post
'post_parent' => [ <post ID> ] //Sets the parent of the new post.
'post_password' => [ ? ] //password for post?
'post_status' => [ 'draft' | 'publish' | 'pending' ] //Set the status of the new post.
'post_title' => [ <the title> ] //The title of your post.
'post_type' => [ 'post' | 'page' ] //Sometimes you want to post a page.
'tags_input' => [ '<tag>, <tag>, <...>' ] //For tags.
'to_ping' => [ ? ] //?
);
// Insert the post into the database
wp_insert_post( $post );
Wordpress는 데이터베이스 추상화를 위한 wp->query API 메서드를 제공합니다.필요한 경우 적절한 쿼리를 작성하여 페이지를 작성할 수 있습니다.
언급URL : https://stackoverflow.com/questions/1186026/automatically-create-page-in-wordpress
반응형
'programing' 카테고리의 다른 글
WordPress 테마에 jQuery를 포함하려면 어떻게 해야 합니까? (0) | 2023.03.15 |
---|---|
스프링 - 로컬 파일 시스템에 저장하지 않고 대용량 멀티파트 파일 업로드를 데이터베이스로 스트리밍하는 방법 (0) | 2023.03.15 |
useReducer 액션이 두 번 디스패치되었습니다. (0) | 2023.03.15 |
잘못된 디코딩으로 인해 특수 문자에 대한 워드프레스 검색에 실패했습니다. (0) | 2023.03.15 |
TypeScript에서는 강력한 타입의 함수를 파라미터로 사용할 수 있습니까? (0) | 2023.03.15 |