WordPress主题制作

  1. 主页
  2. 文档
  3. WordPress主题制作
  4. functions.php制作(参考2020主题)
  5. theme_support

theme_support

第一步,定义函数:
function twentytwenty_theme_support()

第二步,增加钩子:
add_action( ‘after_setup_theme’, ‘twentytwenty_theme_support’ );

在twentytwenty_theme_support里:
包括

  1. add_theme_support

 

 

// Add default posts and comments RSS feed links to head.
add_theme_support( ‘automatic-feed-links’ );

// Custom background color.
add_theme_support(
‘custom-background’,
array(
‘default-color’ => ‘f5efe0’,
)
);

// Set content-width.
global $content_width;
if ( ! isset( $content_width ) ) {
$content_width = 580;
}

/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( ‘post-thumbnails’ );

// Set post thumbnail size.
set_post_thumbnail_size( 1200, 9999 );

// Add custom image size used in Cover Template.
add_image_size( ‘twentytwenty-fullscreen’, 1980, 9999 );

// Custom logo.
$logo_width = 120;
$logo_height = 90;

// If the retina setting is active, double the recommended width and height.
if ( get_theme_mod( ‘retina_logo’, false ) ) {
$logo_width = floor( $logo_width * 2 );
$logo_height = floor( $logo_height * 2 );
}

add_theme_support(
‘custom-logo’,
array(
‘height’ => $logo_height,
‘width’ => $logo_width,
‘flex-height’ => true,
‘flex-width’ => true,
)
);

/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded

这篇文章对您有用吗?

我们要如何帮助您?