我有大约2000篇文章,标题如下:
[i like apples]
我想让他们:[I Like Apples]
我用了WP Title Case plugin, 但问题是这个插件只是利用了帖子本身的标题,所以h1
看起来正常,但<title>
在里面<head>
仍未大写。我猜真正的非大写标题是从数据库中提取的。可能有一个SQL脚本来将数据库表中的列大写,或者有一个php脚本来更改<title>
在head中转换为正常格式?
我有大约2000篇文章,标题如下:
[i like apples]
我想让他们:[I Like Apples]
我用了WP Title Case plugin, 但问题是这个插件只是利用了帖子本身的标题,所以h1
看起来正常,但<title>
在里面<head>
仍未大写。我猜真正的非大写标题是从数据库中提取的。可能有一个SQL脚本来将数据库表中的列大写,或者有一个php脚本来更改<title>
在head中转换为正常格式?
EDIT: WP Title Hook
好的,如果您使用的是wp\\u title(您可能是,这是默认设置),那么该函数中应该有两个您可以使用的过滤器。第一个是wp\\u title\\u parts,它返回分解为数组的标题。
function wp_title_capitalize( $title_parts ) {
// Only uppercases the words of the first element (should be the page title)
$title_parts[0] = ucwords( $title_parts[0] );
return $title_parts;
}
add_filter( \'wp_title_parts\', \'wp_title_capitalize\' );
或者,如果您对整个事情都可以运行大写过滤器,那么您可以在wp\\u title上运行它function wp_full_title_capitalize( $title, $sep, $seplocation ) {
// Uppercases the entire title
$title = ucwords( $title );
return $title;
}
add_filter( \'wp_title\', \'wp_full_title_capitalize\' );
第二个答案更容易理解,因为它贯穿于整个事情,但是如果你的标题看起来像About Us | COMPANY NAME
那么,您可能想选择第一个选项。一如既往,使用挂钩和;过滤器,这些进入功能。主题的php。
Old Answer (CSS ONLY)
如果你只是担心显示器,你可以申请text-transform: capitalize;
到h1的CSS。http://www.w3schools.com/cssref/playit.asp?filename=playcss_text-transform&preval=capitalize
您可以在函数中使用wordpress挂钩。php,但正如socki03所回答的,我认为这更好一些
add_filter( \'wp_title\', \'ucwords\' );
我仍然认为这有点过头了function wp_full_title_capitalize( $title, $sep, $seplocation ) {
// Uppercases the entire title
$title = ucwords( $title );
return $title;
}
add_filter( \'wp_title\', \'wp_full_title_capitalize\' );
我无法评论他的答案,所以我将此作为一个答案:)我有大约2000本书。如何自动删除具有这些标题的帖子?例如