最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

posts - wp_insert_post -> post_name - works only for administrator

programmeradmin9浏览0评论

My code

$post = array(
    'post_title'    => "hello-world",
    'post_name' =>    "hello-world-mytext-here",
    'post_content'  => "bla bla bla,
    'post_status'   => 'pending',
    'post_type' => 'my_item' //custom post type
);
$pid = wp_insert_post($post);

The problem is :

  1. When I am trying to insert like Administrator -> post_name works as well ! So, post slug changed like I want.
  2. If I do log-in like user and trying to insert post, the post_name had same slug like a title ! Without my addition text.

Where I wrong ?

发布评论

评论列表(0)

  1. 暂无评论