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

5 replies
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 -
#call #save #settings #wordpress
  • {{ DiscussionBoard.errors[1440629].message }}
    • Profile picture of the author wgn_white
      Thanks for pointing the post.
      It was complete code.
      I will try to implement it.
      Signature
      PANGERAN.ORG where I blog.
      {{ DiscussionBoard.errors[1440637].message }}
  • Profile picture of the author edynas
    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
    variable= get_option('templatename_css_style');
    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
    {{ DiscussionBoard.errors[1441299].message }}
    • Profile picture of the author wgn_white
      Originally Posted by edynas View Post

      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

      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.
      Signature
      PANGERAN.ORG where I blog.
      {{ DiscussionBoard.errors[1441724].message }}
      • Profile picture of the author edynas
        Banned
        Originally Posted by wgn_white View Post

        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.
        It is but like i said don't make it a must as for instance I have well over 300 websites and more then half still run on wp 2.1 and yes i know i should update but these were set and forget sites and I know there are many other people out there having wordpress sites on way older versions

        Edwin
        {{ DiscussionBoard.errors[1441832].message }}

Trending Topics