如何在查询帖子中post_staus =>'发布'后发帖?

时间:2014-07-07 18:46:28

标签: wordpress

我尝试了以下内容:

$insert = $wpdb->insert( $prefix."posts", array("post_title" => $posTitle,"post_content" => $postContent,"post_status" => "publish","post_type" =>"product"));

使用此查询我在从管理员检查我的帖子时插入帖子并且当我从后端更新帖子时单击视图不起作用然后它将起作用但我想要查看帖子而不更新它来自管理员意味着afetr插入帖子查询帖子应该也可以使用:

add_post_meta( $select[0]->productsId, '_wti_like_count', 0, true );
add_post_meta( $select[0]->productsId, '_wti_unlike_count', 0, true );
add_post_meta( $select[0]->productsId, '_wti_total_count', 0, true );

没有任何成功。有人可以帮助解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

您不应该为此目的使用插页。

这正是您正在尝试做的功能。

wp_insert_post() - http://codex.wordpress.org/Function_Reference/wp_insert_post

$post_id = wp_insert_post( array(
    'post_title'   => $posTitle,
    'post_content' => $postContent,
    'post_type'    => 'product',
    'post_status'  => 'publish',
) );

帖子标题变量有意拼写错误以匹配提供的示例。