WordPress 101 – Part 6: How to add Theme Features with add_theme_support
视频学习参考: https://www.youtube.com/watch?v=ghmdq1hEm14&list=PLriKzYyLb28nUFbe0Y9d-19uVkOnhYxFE&index=6
1.设置主题自定义背景图, 打开functions.php
add_theme_support(‘custom_background’); // 从WordPress 3.9开始支持
刷新后就可以在外观中看到背景 点击进入即可进行设置
2.设置头部自定义背景设置,打开functions.php
add_theme_support(‘custom-header’);
打开header.php
<img src=”<?php header_image(); ?>” height=” <?php echo get_custom_header()->height; ?> ” width=” <?php echo get_custom_header()->width; ?> ” alt=”” />
3.文章图片的缩略图, 打开functions.php
add_theme_support(‘post-thumbnails’);
打开index.php
<div class=”thumbnail-img”><?php the_post_thumbnail(‘thumbnail’); ?></div>
Super Simple!