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.

  • 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, 2011 at 13:53

2 Answers 2


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 )


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



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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