在开发 WordPress 主题时,add_theme_support 函数非常有用。
add_theme_support 就像一把钥匙,可以打开各种 WordPress 的功能。
一般的,只需要在 functions.php 中使用 add_theme_support 函数就可以了。如果是使用钩子的话,务必使用 after_setup_theme 钩子;在 init 钩子中执行相关代码的话,就太迟了。
使用举例:
add_theme_support( 'title-tag' );
add_theme_support( 'custom-logo', array(
'height' => 480,
'width' => 720,
) );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
add_theme_support(
'custom-background',
array(
'default-color' => '0B3B41',
'default-image' => get_template_directory_uri().'/images/bg.jpg',
)
);
add_theme_support( 'custom-header' );
-
WordPress函数:get_template_part 用法简介get_template_part 有什么优点
-
WordPress函数:wp_is_writable 判断路径是否可写检查文件权限的方便函数
-
WordPress函数:wp_title 主题页面标题WordPress 页面标题SEO
-
WordPress函数:wp_timezone_string 返回后台设置的时区当前设置的时区是什么
-
WordPress函数:current_time 返回当前时间在 WordPress 如何获取当前时间
-
WordPress函数:set_query_var 与 get_query_var 设置与获取查询参数一对WordPress函数
暂无评论,抢个沙发...