• Hi,

    maybe someone can help me.

    Isn’t it as simple as it sounds? I tried around with the Functions.php, but without success.

    I would like to add a form in the admin-area of my template (just like the header-image-page in the kubrick-theme.

    The “user” should be able to change a value and this value should be accessible from the template.
    E.g. changing a “welcome” message without having to change the code.

    Someone any idea?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Look at how Kubrick handles putting a menu item on the screen to navigate to the theme header settings page, how it puts a form on the screen and stores the values when the form is submitted. It’s pretty straight forward to do that sort of thing – assuming that you’re familiar with HTML forms, PHP, storing values in the WP database, etc.

    You might want to tell us what theme you’re trying to work with? Or it is your own custom theme?

    Either way the easiest approach is to copy something that works and modify it for your own needs.

    Thread Starter gegenalles

    (@gegenalles)

    Thank you.

    I use the kubrick-theme but it is heavy modified.
    That’s what I did, i looked up Kubrick’s functions.php.
    I know how to work with template tags, custom fields etc. The functions.php however is not very easy to understand.

    Ok, they use color pickers, etc. and I only need 2 Text-Forms. Shouldn’t that be quite simple?

    I need to tell wordpress to:
    Create a Admin Page
    Create 2 Labels, 2 Text-Boxes and one submit-button.
    Store the content of Text-Boxes in Database

    Then there should be a template tag or something that lets me embed the text in the template.

    Thanks to someone who could give me a hint.

    Either way the easiest approach is to copy something that works and modify it for your own needs.

    Here’s the basis of getting a menu item in the nav for theme options. This is extremely basic code that you will need to expand upon. If you need to hire someone do all this for you then you could contact me privately via my Web site or join the WP Pro list and hire someone there.

    <?php
    add_theme_page("New Options", "New Options", 'edit_themes', basename(__FILE__), 'my_new_options);
    
    function my_new_options() {
    echo 'hello';
    // put your HTML form here and whatever processing
    // code you need to grab submitted form vars
    // and store them in the database somewhere
    }
    ?>
    Thread Starter gegenalles

    (@gegenalles)

    Thanks again, I’ve got it now!
    I had to look for Plugin-Development, not for Theme Development.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Simple?! Custom Variable in a Template’ is closed to new replies.