最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

What is difference between add_theme_support and Theme Customization API?

programmeradmin1浏览0评论

I'm interested in adding customizable features to a theme. What is the difference between the following

add_theme_support(...)

and

Theme Customization API

Are they just 2 different ways to accomplish the same thing? Or is add_theme_support() limited on what it can control, where the Theme Customization API is more open-ended for any type of custom functionality?

I'm interested in adding customizable features to a theme. What is the difference between the following

add_theme_support(...)

and

Theme Customization API

Are they just 2 different ways to accomplish the same thing? Or is add_theme_support() limited on what it can control, where the Theme Customization API is more open-ended for any type of custom functionality?

Share Improve this question asked Jun 6, 2019 at 15:54 Jake WilsonJake Wilson 2832 gold badges4 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

They're not directly really related, and do different things, except for a couple of situations.

The Customization API is a way of registering settings and controls in the Customizer, and is very flexible. You can use it to add controls for just about anything in your theme.

add_theme_support(), on the other hand, lets your theme tell WordPress (or plugins) that it supports certain features, so that WordPress can enable or change certain functionality. For example, adding support for post-thumbnails will add the featured image option to posts, while adding support for title-tag will add a <title> element to the template automatically. If you don't declare support, then WordPress will turn these off, since your theme's templates presumably don't need them.

The features you can declare support for cover a number of things, but only some of them add things to the Customizer. For example, custom-background and custom-logo add fields to the Customizer for setting a background and logo. Under the hood these are added with the Theme Customization API. So adding support for these features is effectively a way of adding a standard field/set of fields for certain features, and by using them you don't need to write as much code, and can have behaviour 100% consistent with other themes.

发布评论

评论列表(0)

  1. 暂无评论