我正在创建自定义帖子类型,并希望在“创建新帖子”部分的标题字段中操作占位符文本。
要求:
- 它只能针对一种特定的帖子类型,而不是针对所有帖子。
- 它不能反映帖子类型的名称,它必须是完全自定义的文本。
- 它不必可从 wordpress 管理部分进行编辑,自定义文本可以放置在 functions.php 文件中的函数内。
小智 5
你可以把这个片段放在你的functions.php
function change_default_title( $title ){
$screen = get_current_screen();
if ( 'your_custom_post_type' == $screen->post_type ){
$title = 'Your custom placeholder text';
}
return $title;
}
add_filter( 'enter_title_here', 'change_default_title' );
Run Code Online (Sandbox Code Playgroud)
那应该改变标题。
发现于:https : //gist.github.com/FStop/3094617