반응형
wp_insert_post를 사용하여 워드프레스로 POST permalink/slug을 설정하는 방법
를 사용하여 간단한 스크립트를 작성하고 있습니다.wp_insert_post()
블로그에 글을 올립니다. 하지만 여기서 한가지 문제는 URL의 제목과 슬래그를 다르게 만들고 싶습니다.
어떻게 하면 좋을까요?
예를 들어 다음과 같습니다.
제목 : 다이어트를 성공시키는 방법
슬래그:7-ways-to-make-succes-Diet
post_name은 제목을 설정하고 post_name은 slug를 설정합니다.그래서:
// Create post object
$my_post = array(
'post_title' => 'How to make your diet success',
'post_name' => '7-ways-to-make-succes-Diet',
'post_content' => 'my content',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(8,39)
);
// Insert the post into the database
wp_insert_post( $my_post );
언급URL : https://stackoverflow.com/questions/5897758/how-to-set-post-permalink-slug-in-wordpress-using-wp-insert-post
반응형
'programing' 카테고리의 다른 글
Woocommerce의 마지막에 품절된 제품 표시 (0) | 2023.03.23 |
---|---|
create-react-app index.js 파일을 테스트합니다. (0) | 2023.03.23 |
JSON에서 base64 인코딩된 데이터 직렬화 (0) | 2023.03.23 |
Spring Boot 응용 프로그램에서 테이블 재생을 사용하지 않도록 설정합니다. (0) | 2023.03.23 |
오류: 이 메서드는 단일 노드에서만 실행됩니다.대신 0이 발견됨 (0) | 2023.03.23 |