wordpress默认密码_向WordPress 20主题添加其他默认标题

wordpress默认密码

The Twenty Ten theme comes with eight default headers. Any default header that you set is replaced with the “featured image” of a post. You can only see the new header when viewing that post. In this week’s WordPress Quick Tip we’ll see how simple it is to add additional headers to the Header’s Panel.

“二十十”主题带有八个默认标题。 您设置的任何默认标题都将替换为帖子的“特色图片”。 您只能在查看帖子时看到新标题。 在本周的WordPress快速提示中,我们将看到在“标题面板”中添加其他标题是多么简单。

观看截屏 (Watch the Screencast)

Functions.php (Functions.php)

Open up the functions.php file of the Twenty Ten theme. Locate the following section:

打开“二十十”主题的functions.php文件。 找到以下部分:

// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.

What follows is an array listing the current default headers and their location. To add your own, add a comma after the last parenthesis of the array of sunset header. Here’s an example of what it can look like after adding two more headers:

接下来是一个列出当前默认标头及其位置的数组。 要添加自己的内容,请在日落标头数组的最后一个括号后面添加一个逗号。 这是添加两个标头后的示例:


register_default_headers( array(
‘berries’ => array(
‘url’ => ‘%s/images/headers/berries.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/berries-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Berries’, ‘twentyten’ )
),
‘cherryblossom’ => array(
‘url’ => ‘%s/images/headers/cherryblossoms.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/cherryblossoms-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Cherry Blossoms’, ‘twentyten’ )
),
‘concave’ => array(
‘url’ => ‘%s/images/headers/concave.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/concave-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Concave’, ‘twentyten’ )
),
‘fern’ => array(
‘url’ => ‘%s/images/headers/fern.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/fern-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Fern’, ‘twentyten’ )
),
‘forestfloor’ => array(
‘url’ => ‘%s/images/headers/forestfloor.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/forestfloor-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Forest Floor’, ‘twentyten’ )
),
‘inkwell’ => array(
‘url’ => ‘%s/images/headers/inkwell.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/inkwell-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Inkwell’, ‘twentyten’ )
),
‘path’ => array(
‘url’ => ‘%s/images/headers/path.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/path-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Path’, ‘twentyten’ )
),
‘sunset’ => array(
‘url’ => ‘%s/images/headers/sunset.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/sunset-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Sunset’, ‘twentyten’ )
),
‘waterfall’ => array(
‘url’ => ‘%s/images/headers/waterfall.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/waterfall-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Waterfall’, ‘twentyten’ )
),
‘mountain’ => array(
‘url’ => ‘%s/images/headers/mountain.jpg’,
‘thumbnail_url’ => ‘%s/images/headers/mountain-thumbnail.jpg’,
/* translators: header image description */
‘description’ => __( ‘Mountain’, ‘twentyten’ )
)
) );

让我们剖析一下代码。 (Lets dissect the code a little bit.)

register_default_headers : This is the function that creates and displays our default headers. It accepts an array of parameters.

register_default_headers:这是创建和显示默认标题的函数。 它接受参数数组。

name: Sets a value with our headers name. We can then set an array of additional values and keys.

name:使用标题名称设置一个值。 然后,我们可以设置其他值和键的数组。

url: Relative path to the header image. Notice that the current path is /images/headers/image_name.jpg

url:标题图片的相对路径。 请注意,当前路径为/images/headers/image_name.jpg

thumbnail_url: Relative path to a thumbnail of the header image. Current path is /images/headers/image_name-thumbnail.jpg

thumbnail_url:标题图片缩略图的相对路径。 当前路径是/images/headers/image_name-thumbnail.jpg

description: A description of the image. This would be display upon hovering over the image inside the Headers Panel.

description:图像的描述。 将鼠标悬停在页眉面板中的图像上时,将显示该内容。

注意事项 (Things to Note)

The Twenty Ten header is 940×198, anything bigger than that would be resized; anything smaller would be stretch to fit those dimensions. The thumbnail images can be set to any dimensions, 230×48 is the default. The images can only be .jpg or they will be ignored and won’t be displayed.

“二十十”标头的尺寸为940×198,大于调整后的尺寸; 任何较小的物体都会拉伸以适合这些尺寸。 缩略图可以设置为任意尺寸,默认为230×48。 图片只能是.jpg,否则将被忽略并且不会显示。

翻译自: https://www.wpbeginner.com/wp-themes/adding-additional-default-headers-to-the-wordpress-twenty-ten-theme/

wordpress默认密码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值