WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a drawing canvas on some of my Wordpress' post pages, where users can draw on. Upon drawing, my JS code currently sends the user's drawing to a php file. This is where I store the array in JSON format in .txt files. Whenever the page is loaded by someone else, JS loads these JSON files on start, so you see other people's sketches and you can draw on it as well - where the txt files get altered etc etc.

But is it possible to use Wordpress' custom fields? So every post has their own variable where the drawing array is stored. I have no idea what type of custom field to use.. Or whether there is a plugin out there that might be helpful with helping me achieve what I want. Or maybe not a good idea at all to do it this way.

Thanks in advance.

share|improve this question
I don't see any problem to saving it as an options. Are you asking for how to save data on wordpress database? – Sisir Oct 31 '11 at 13:53
up vote 1 down vote accepted

Yes! Yes you can!

You can use this code to retrieve a stored option:

$value = get_post_meta($post->ID,'customfieldname',true); // where true means only return 1 custom field by this name

You can use this code to save a stored option:


The above code will need to be inside the post loop, though you can supply a post ID from elsewhere, say a GET variable etc and avoid another query

You can also store multiple values with the same custom field name. The value to be stored is a string value, as such a json string is good. The same is true of get_option and update_option for global values.

You can also use meta boxes to customize the UI for showing these values. Custom fields whose names start with _ will not be shown in the custom fields meta box in the back end ( which is how wordpress hides its own internal custom fields from the end user )

share|improve this answer

Sure you can use a custom field and there are various plugins how there that make using these custom fields very easy.



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.