最好的选择是连接到post类型转换并通过PHP创建第二个(自定义)post(类型)。以下是一个可以实现以下功能的函数:
// Automatically create a news (regular post in category ID 1 = news) when a wiki post (custom post type) has been published
function nxt_create_news($new_status, $old_status, $nxt_wiki_post) {
if(\'publish\' === $new_status && \'publish\' !== $old_status && $nxt_wiki_post->post_type === \'wiki\') {
$nxt_post_author = $nxt_wiki_post->post_author;
$nxt_wiki_permalink = get_post_permalink($nxt_wiki_id);
$nxt_wiki_title = $nxt_wiki_post->post_title;
$nxt_postarr = array(
\'post_author\' => $nxt_post_author,
\'post_content\' => \'The wiki entry \' . $nxt_wiki_title . \' has just been published.<br /><br /><a href="\' . $nxt_wiki_permalink . \'" title="\' . $nxt_wiki_title . \'">Check out wiki entry</a>.\',
\'post_title\' => \'The wiki entry \' . $nxt_wiki_title . \' has been published\',
\'post_status\' => \'publish\',
\'post_category\' => array(1),
);
$nxt_post_id = wp_insert_post($nxt_postarr);
set_post_thumbnail(get_post($nxt_post_id), \'1518\');
}
}
add_action( \'transition_post_status\', \'nxt_create_news\', 10, 3 );
对你来说,可能恰恰相反。在创建特定类别的常规帖子后,您可以创建自定义帖子类型。我希望上面的例子提供了足够的上下文,但只要问问你是否需要更多的输入。