Adding an Upload Field in Your Theme Options Panel

Adding an Upload Field in Your Theme Options Panel

For anyone banging their heads against their keyboards trying to add upload functionality to their options panel, hopefully this can help.

All credit goes to Webmaster-Source.com’s article, you can read here.

I just wanted to try to make it a little more clear and show you the bits and pieces of code that I am using.

Step 1. Register your setting in your functions.php:

 

Step 2. Also, make sure you add it inside your form:

 

Step3. Getting your HTML ready in Your Form:

 

Step 4. Calling the Scripts:

You need to call the appropriate scripts:

Step 5. Finding last post->ID:

To be able to see the ‘insert into post’ button, WordPress needs a post->ID. Put this in your options panel function, so we can call it in your jQuery script[step 6]

 

Step 6. The jQuery Script -> uploadLogo.js

Here is how your jQuery should look. Basically it looks for the element #logoUpload, which we set on the input field in our form. Then it plugs the post->ID into the thickbox URL.

 

 

 

No Comments

Sorry, the comment form is closed at this time.