Title: Theme Mods API or Settings API?
Author: Justin Tadlock
Published: November 26, 2014

---

 [  ](https://profiles.wordpress.org/greenshady/) [Justin Tadlock](https://profiles.wordpress.org/greenshady/)
11:45 pm _on_ November 26, 2014     
Tags: [Customizer API ( 5 )](https://make.wordpress.org/themes/tags/customizer-api/),
[Settings API ( 5 )](https://make.wordpress.org/themes/tags/settings-api/), [Theme Mods API ( 4 )](https://make.wordpress.org/themes/tags/theme-mods-api/)

# Theme Mods API or Settings API?

A few days ago, Chip Bennett wrote a good tutorial on the APIs related to theme 
options and broke down how those APIs can/should be used depending on the context.
If anyone can really go in depth with theme options, it’s Chip. I’m hoping we see
more from him on theme options in the future. I highly encourage [reading his post](https://make.wordpress.org/themes/2014/11/24/understanding-the-apis-related-to-theme-options/)
to make sure you have the foundation you need.

In this post, I want to cover a question that has been popping up, particularly 
about the Theme Mods vs. Settings and which to use.

Essentially, we allow three different methods of handling theme options on the repository(
technically, there are other methods, but we allow three):

 * CustomizerCustomizer Tool built into WordPress core that hooks into most modern
   themes. You can use it to preview and modify many of your site’s appearance settings.
   APIAPI An API or Application Programming Interface is a software intermediary
   that allows programs to interact with each other and share data in limited, clearly
   defined ways. + Theme Mods
 * Customizer API + Settings API
 * Theme options page created with the Settings API

The customizer is so much easier to use and requires a lot less code. It’s something
I strongly recommend. It’s also what I’ll be focusing on as I write more about theme
options. This post is going to focus on whether you should use the Theme Mods API
or the Settings API for storing options.

## Theme Mods

The thing many theme authors get hung up on is that theme mods are saved on a per-
theme basis. So, this means when you switch child themes, any theme mod options 
will need to be saved again for the new child themeChild theme A Child Theme is 
a customized theme based upon a Parent Theme. It’s considered best practice to create
a child theme if you want to modify the CSS of your theme. [https://developer.wordpress.org/themes/advanced-topics/child-themes/](https://developer.wordpress.org/themes/advanced-topics/child-themes/).
Sometimes, users might even see this as “losing their settings”.

This is both a blessing and a curse. I love it because it allows my users to have
seasonal or holiday child themes. Imagine you wanted to have a child theme specifically
for the Christmas season with its own color scheme. It’s nice to be able to change
those color options just for the Christmas child theme.

What happens when you switch back to your regular theme in January? Well, it still
has all of its unique options saved for it. There’s no work involved except for 
switching child themes.

The other nice thing is that coreCore Core is the set of software required to run
WordPress. The Core Development Team builds WordPress. WP has hooksHooks In WordPress
theme and development, hooks are functions that can be applied to an action or a
Filter in WordPress. Actions are functions performed when a certain event occurs
in WordPress. Filters allow you to modify certain functions. Arguments used to hook
both filters and actions look the same. already built in for each new theme mod 
you create. That’s very nice for child theme authors who want to quickly filterFilter
Filters are one of the two types of Hooks [https://codex.wordpress.org/Plugin_API/Hooks](https://codex.wordpress.org/Plugin_API/Hooks).
They provide a way for functions to modify data of other functions. They are the
counterpart to Actions. Unlike Actions, filters are meant to work in an isolated
manner, and should never have side effects such as affecting global variables and
output. options in the parent theme.

## Settings API

I’m less of a fan of the Settings API because it means that an option is saved based
on the parent theme. The great thing about it is that users only have to save options
once and not save them again if they switch child themes (technically, you can get
around that if anyone wants me to explain the code).

Going back to the Christmas theme example: What happens when you switch to a Christmas
child theme? In this scenario, you’d have to change your colors. Then, you’d have
to change them again when switching back to your non-holiday child theme.

However, not all theme options need to be changed when a user switches child themes.
Some options make more sense to stay the same, regardless of child theme.

## What about a combination?

Actually, you can use a combination of both the Theme Mods API and Settings API 
with the customizer. It’s not an either/or thing. That’s just another example of
its awesomeness. I even encourage this practice in some situations.

I imagine things like colors and fonts would generally make more sense as theme 
mods. But, an option to either show excerpts or content on the front page might 
be better served via the Settings API.

Each option should really be given this consideration rather than blindly doing 
one or the other.

[#customizer-api](https://make.wordpress.org/themes/tags/customizer-api/), [#settings-api](https://make.wordpress.org/themes/tags/settings-api/),
[#theme-mods-api](https://make.wordpress.org/themes/tags/theme-mods-api/)

### Share this:

 * [  Threads ](https://make.wordpress.org/themes/2014/11/26/customizer-theme-mods-api-or-settings-api/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/themes/2014/11/26/customizer-theme-mods-api-or-settings-api/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/themes/2014/11/26/customizer-theme-mods-api-or-settings-api/?share=bluesky)
 * [  Facebook ](https://make.wordpress.org/themes/2014/11/26/customizer-theme-mods-api-or-settings-api/?share=facebook)
 * [  X ](https://make.wordpress.org/themes/2014/11/26/customizer-theme-mods-api-or-settings-api/?share=x)
 * [  LinkedIn ](https://make.wordpress.org/themes/2014/11/26/customizer-theme-mods-api-or-settings-api/?share=linkedin)

 * [Login to Reply](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fthemes%2F2014%2F11%2F26%2Fcustomizer-theme-mods-api-or-settings-api%2F%23respond&locale=en_US)

 1.  ![](https://secure.gravatar.com/avatar/63b496ec3806485229b4f934b26643dad6e734ca6e6ef7b38c846205b01cd37f?
     s=32&d=mm&r=g)
 2.   [Weston Ruter](https://profiles.wordpress.org/westonruter/)  11:53 pm _on_ November
     26, 2014
 3.  CustomizerCustomizer Tool built into WordPress core that hooks into most modern
     themes. You can use it to preview and modify many of your site’s appearance settings.
     for the win!
 4.  ![](https://secure.gravatar.com/avatar/7b4c8e2413c3cf4768d958fa7257e7f2585760d399a686b0c2e86415b8c796b4?
     s=32&d=mm&r=g)
 5.   [nikeo](https://profiles.wordpress.org/nikeo/)  7:37 am _on_ November 27, 2014
 6.  Thanks for your post [@greenshady](https://profiles.wordpress.org/greenshady/).
     I found the child themeChild theme A Child Theme is a customized theme based upon
     a Parent Theme. It’s considered best practice to create a child theme if you want
     to modify the CSS of your theme. [https://developer.wordpress.org/themes/advanced-topics/child-themes/](https://developer.wordpress.org/themes/advanced-topics/child-themes/)
     example really interesting to demonstrate the “dynamic” possibilities offered 
     by theme mods vs settings APIAPI An API or Application Programming Interface is
     a software intermediary that allows programs to interact with each other and share
     data in limited, clearly defined ways..
 7.  ![](https://secure.gravatar.com/avatar/f6c58d47d89672b0e5684f27a1c16174b1457962a9b01911d49e17cb1dc493bd?
     s=32&d=mm&r=g)
 8.   [ro_sev](https://profiles.wordpress.org/ro_sev/)  11:48 pm _on_ November 27, 
     2014
 9.  thanks
 10. ![](https://secure.gravatar.com/avatar/ce9aafe20297b5e9b5b4f29ecb79a9954de779b5987d78dadc12bc1ffe5153df?
     s=32&d=mm&r=g)
 11.  [mojaray2k](https://profiles.wordpress.org/mojaray2k/)  1:51 am _on_ November
     28, 2014
 12. I am using the settings APIAPI An API or Application Programming Interface is 
     a software intermediary that allows programs to interact with each other and share
     data in limited, clearly defined ways. for more site info features like social
     media links and other global data to be displayed site wide. But the Theme Mods
     API just gives me as a developer more ability to involve a designer and end user
     to truly control the final look and feel of their site.
 13. ![](https://secure.gravatar.com/avatar/8ea2daeab2332008d22d8356cf4e2e6458969ed615cd104fd0276ff722580e34?
     s=32&d=mm&r=g)
 14.  [Edward R. Jenkins](https://profiles.wordpress.org/cardiganmedia/)  1:43 am _on_
     December 10, 2014
 15. Hi Justin — I agree that the theme_mod setup is both a blessing and a curse. I’m
     using the customizerCustomizer Tool built into WordPress core that hooks into 
     most modern themes. You can use it to preview and modify many of your site’s appearance
     settings. exclusively for my latest theme, and I was a little frustrated with 
     the way WP handles it. But after playing with it for a bit, I can certainly see
     why it’s done that way.

### Leave a Reply 󠀁[Cancel reply](https://make.wordpress.org/themes/2014/11/26/customizer-theme-mods-api-or-settings-api/?output_format=md#respond)󠁿

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fmake.wordpress.org%2Fthemes%2F2014%2F11%2F26%2Fcustomizer-theme-mods-api-or-settings-api%2F&locale=en_US)
to post a comment.

This site uses Akismet to reduce spam. [Learn how your comment data is processed.](https://akismet.com/privacy/)

# Post navigation

[← Handbook refresh.](https://make.wordpress.org/themes/2014/11/26/handbook-refresh/)

[Global group meeting We had a meeting today… →](https://make.wordpress.org/themes/2014/11/27/global-group-meeting-we-had-a-meeting-today/)