WordPress文章/页面编辑界面的标题输入提示文字默认为“在此键入标题”,如果你想修改为其他文字,比如“输入文章标题”,如下图:

可以将下面的代码添加到当前主题的 functions.php 即可:
/**
* 更改标题输入框提示文字
* https://www.wpdaxue.com/change-title-prompt-text.html
*/
function change_default_title( $title ){
$screen = get_current_screen();
if( 'post' == $screen->post_type ) {
$title = '输入<a href="https://www.wpdaxue.com/tag/%e6%96%87%e7%ab%a0%e6%a0%87%e9%a2%98" title="查看与【文章标题】相关的文章" target="_blank" rel="noopener">文章标题</a>';
}
return $title;
}
add_filter( 'enter_title_here', 'change_default_title' ); |
/**
* 更改标题输入框提示文字
* https://www.wpdaxue.com/change-title-prompt-text.html
*/
function change_default_title( $title ){
$screen = get_current_screen();
if( 'post' == $screen->post_type ) {
$title = '输入<a href="https://www.wpdaxue.com/tag/%e6%96%87%e7%ab%a0%e6%a0%87%e9%a2%98" title="查看与【文章标题】相关的文章" target="_blank" rel="noopener">文章标题</a>';
}
return $title;
}
add_filter( 'enter_title_here', 'change_default_title' );
注:你可以修改第 8 行的 post 为其他文章类型,比如,页面为 page。如果你还有其他自定义文章类型,比如 book,也是可以的。第 9 行是提示文字。
灵活地使用 IF 语句进行判断,可以给不同的文章类型设定不同的提示文字,比如:
if( 'post' == $screen->post_type ) {
$title = '输入文章标题';
} elseif ('page' == $screen->post_type) {
$title = '输入页面标题';
} elseif ('book' == $screen->post_type) {
$title = '输入书籍标题';
} |
if( 'post' == $screen->post_type ) {
$title = '输入文章标题';
} elseif ('page' == $screen->post_type) {
$title = '输入页面标题';
} elseif ('book' == $screen->post_type) {
$title = '输入书籍标题';
}
来源:
https://www.wpdaxue.com/change-title-prompt-text.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32443.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57