admin管理员组文章数量:1426932
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?
1 Answer
Reset to default 0They'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.
本文标签: What is difference between addthemesupport and Theme Customization API
版权声明:本文标题:What is difference between add_theme_support and Theme Customization API? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745428983a2658243.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论