WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Theme Customizer not able to add a new field to current settings (6 posts)

  1. BenjaminRMueller
    Member
    Posted 2 years ago #

    So I have been playing with the Theme Customizer with the Twenty Eleven theme and I added a new field to adjust the twentyeleven_theme_options[link_color] which worked perfect but when I try to create a new field twentyeleven_theme_options[text_color] and save this field it doesn't get saved.

    It looks like if the setting was not been setup before the theme customizer then it can not be added. Not sure if anyone else has ran into this issue or if it is in issue on my end.

    Here is the code I am using:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

  2. BenjaminRMueller
    Member
    Posted 2 years ago #

    Here is the code I am using:

    http://pastebin.com/qeSAQm7p

  3. esmi
    Forum Moderator
    Posted 2 years ago #

  4. BenjaminRMueller
    Member
    Posted 2 years ago #

    Yes, I actually used that post while I was writing my code so all of my code follows along with Otto's.

  5. Jon Cave
    WordPress Dev
    Posted 2 years ago #

    It doesn't work because twentyeleven_theme_options_validate() is run on sanitize_option(), so your custom key is stripped out. If you want to work with the twentyeleven_themem_options option then you'll have to filter twentyeleven_theme_options_validate as well to allow the text_color key through.

  6. BenjaminRMueller
    Member
    Posted 2 years ago #

    That's what it was Jon. I forgot to add that variable to the validate function in the theme options file. Everything worked perfectly after adding that. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.