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 shortcode that is built using a Thickbox form with various inputs that return the values. This works fine. However, I would like the existing values (if present) to re-populate the form if the user opens it again.

Here is an example of my shortcode:

[schema type="person" name="Andrew Norcross" description="I make interwebs" ]

I have a working jQuery match function to find the shortcode if it exists:

var code = $('div#wp-content-editor-container textarea').text().match(/\[schema(.*)\]/g);

the code above does get the entire shortcode as a string, but I'm at a loss for how to process it efficiently to get the values I want.

so what I want to accomplish:

  1. check for a specific part inside the shortcode data (i.e. name="Andrew Norcross")
  2. get the value inside the quotes and insert it into the field on the form

I've tried a few ways but nothing seems to function as expected.

share|improve this question
up vote 2 down vote accepted

Try something like this...

var code = $('div#wp-content-editor-container textarea').text().match(/\[(schema.*)\]/);
code = '<' + code[1] + '>';
share|improve this answer
perfect! this is exactly what I wanted. – Norcross Nov 2 '12 at 16:53

I would look into using jQuery's .data() function. Because its a shortcode, you can't really store values from the form into the 's data attributes and retrieve them that way, storing them with the .data() function seems like your best bet.


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.