0

条件ステートメントがあり、条件が true になったときに、特定の投稿を特定のカテゴリにプッシュしたいと考えています。

何かのようなものwp_push_post($post, $category)

この仕事をする機能は存在しますか?

4

2 に答える 2

0

使用する

 <?php wp_insert_post( $post, $wp_error ); ?> 

$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.
  'comment_status' => [ 'closed' | 'open' ] // 'closed' means no comments.
  'ping_status' => [ 'closed' | 'open' ] // 'closed' means pingbacks or trackbacks turned off
  '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'| 'future' | 'private' ] //Set the status of the new post. 
  'post_title' => [ <the title> ] //The title of your post.
  'post_type' => [ 'post' | 'page' | 'link' | 'nav_menu_item' | custom post type ] //You may want to insert a regular post, page, link, a menu item or some custom post type
  'tags_input' => [ '<tag>, <tag>, <...>' ] //For tags.
  'to_ping' => [ ? ] //?
  'tax_input' => [ array( 'taxonomy_name' => array( 'term', 'term2', 'term3' ) ) ] // support for custom taxonomies. 
);  
于 2012-06-13T11:22:26.997 に答える
0

もう 1 つの興味深いアプローチは、$wpdb を使用することです: http://codex.wordpress.org/Class_Reference/wpdb

于 2012-06-13T12:54:14.723 に答える