Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在wordpress post发布时,是否有任何方法可以生成自动标题_Wordpress - Fatal编程技术网

在wordpress post发布时,是否有任何方法可以生成自动标题

在wordpress post发布时,是否有任何方法可以生成自动标题,wordpress,Wordpress,我有一个自定义的帖子类型,我可以在这里创建帖子和发布 可以是任意随机字符串。 发布帖子时是否有自动修改帖子标题的方法?如果要在后端创建帖子时设置标题,必须使用title\u save\u pre过滤器。它可以创建一个新的帖子或更新一个现有的帖子而不做任何更改 add_filter( 'wp_insert_post_data' , 'modify_your_post_title' , '99', 1 ); function modify_your_post_title( $data ) {

我有一个自定义的帖子类型,我可以在这里创建帖子和发布 可以是任意随机字符串。
发布帖子时是否有自动修改帖子标题的方法?

如果要在后端创建帖子时设置标题,必须使用
title\u save\u pre
过滤器。它可以创建一个新的帖子或更新一个现有的帖子而不做任何更改

add_filter( 'wp_insert_post_data' , 'modify_your_post_title' , '99', 1 ); 

function modify_your_post_title( $data )
{
  if($data['post_type'] == 'rating') { /

    $id = get_the_ID();
    $title = 'Post Title for ' . $id;
    $data['post_title'] =  $title ; //Updates the post title to your new title.
  }
  return $data; // Returns the modified data.
}