Answer the question
In order to leave comments, you need to log in
Wordpress post publishing (api)
Hello! I recently undertook to complete the project for one person. It turned out that he chose the WP engine. Things were going well until I got to importing products from xls. I parsed the document, got an array. I think it's time to write to the database. Stop. How to write there? I smoked Google, nothing smart came up. If anyone knows how to publish posts (a lot, a lot at a time) - then please share your experience.
Answer the question
In order to leave comments, you need to log in
Add programmatically .
# Данные для публикации записи:
$source = array(
'post_title' => 'Заголовок поста.', // - заголовок материала.
'post_name' => 'zagolovok-posta', // - "слаг", синоним пути.
'post_excerpt' => 'Цитата поста.', // - цитата, анонс.
'post_content' => '<p>Содержимое поста.</p>', // - содержимое/контент.
'post_status' => 'publish', // - статус материала: опубликованный.
'post_author' => 1, // - автор материала: пользователь с id=1 (администратор).
'post_type' => 'post', // - тип контента: запись.
'post_category' => array( 43,52 ), // - рубрики.
'tags_input' => 'Добавление постов, WordPress', // - метки/теги.
'comment_status' => 'open' // - комментирование разрешить.
);
# Вставка записи в базу данных:
wp_insert_post($source);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question