How to Save Custom Meta Box Value
-
Hi,
I created a custom meta box via the tutorial found here:
https://codex.www.ads-software.com/Function_Reference/add_meta_boxIt works great and all the only problem is that I want it to show the current set value in the box if there is one set for this post.
Here is the code for the box:
function mybox(){ echo ' <select id="myselect" name="myselectname"> //Need something here to check if there is a current value and show it first if there is <option value="no">None</option> <option value="top">Yes 1</option> <option value="footer">Yes 2/option> </select>'; }
So if I choose Yes 1 in my box it saves great and I can access this saved data from my theme.
However I just need the box to show this value when I go to edit a post. Instead when I go to edit the post, the None value is always showing even though a different value is saved?So basically I need a way of retreiving the current value for the box if there is one set and if so show this option value first I guess.
Should I set up a loop or something and use get_post_meta or is there a simple way?
- The topic ‘How to Save Custom Meta Box Value’ is closed to new replies.