WordPress: How To Save Settings and Call That Value Again?

by 5 replies
6
Hello to all.

I need help.

I'm making a wordpress theme with some admin interface.
My mission is towards "No Hand Code For User".

After reading the WordPress codex about a week ago, I manage to register my admin page under the Appearance tab which what I want.

Now I want to put form in that page which I already know how to and yes, the form appear at that page. But I don't know where to save that options and how to call back the value of the option.

My goal is to make css selector for my users.

This is how I do it so far.

I put all the css files inside one directory and using scandir and readdir, I manage to display the css filename in <option> by using a loop.

What I want, when the users select which css file name and the click save, that file name will be saved.

And then, I will need to call the chosen filename again and then use add_action to hook it to <head> so it will import the css.

Am I making myself clear?

Please enlighten me, I have read the WordPress codex and still don't get it, and I don't have formal lesson on PHP and mySQL database. I'm just enthusiast.

Best regards,
- Guan -
#programming #call #save #settings #wordpress
    • [ 1 ] Thanks
    • [1] reply
    • Thanks for pointing the post.
      It was complete code.
      I will try to implement it.
  • Banned
    Make an admin page where you have a selection of the diffent css files/settings and make those a wordpress option (
    PHP Code:
    update_option('templatename_css_style', 'option_value'); 
    then in your header call the option and act accordingly
    The function Dan points to is nice but will only work starting with wp 2.8+ and it's way to early to expect everyone to have a wp install using that version. Which will mean your theme will break if you rely on that

    Edwin
    • [ 1 ] Thanks
    • [1] reply

    • Thanks for replying.
      I'm working with wordpress 2.8.6 and I think it is good to suggest to people to upgrade to the latest version of WP.
      • [1] reply

Next Topics on Trending Feed