I'm trying to fill WP SEO Structured Data Schema fields with add_post_meta function and it doesn't work properly. I checked one of the posts that's added from Wordpress admin panel and it was saved like this: ‍‍‍‍


looks like this _schema_article is the parent of _schema_article[headline] which I'm trying to save. this is my code:

$my_post = array(
    'post_title'    => "title",
    'post_content'  => "content",
    'post_status'   => 'publish',
    'post_author'   => 1,
$remote_id = wp_insert_post($my_post);
echo $remote_id;
add_post_meta($remote_id, "_schema_article[headline]", "aaa", true);

how can I create something like this JSON-like example above with add_post_meta or other WordPress functions?

1 Answer 1


This is the PHP serialization format, and is used to serialize arrays for storage in the database. Core WordPress functions take care of this process for you. You just need to use an array as the value.

For example, this:

$schema_article = array(
    'headline' => 'aaa',

update_post_meta( $remote_id, '_schema_article', $schema_article );

Will save this value:


If you want to see the original array for a value, get_post_meta() will unserialize it for you.

For example, this:

$schema_article = get_post_meta( $remote_id, '_schema_article', true );

Will return (as seen via var_dump()):

array(1) {
  string(3) "aaa"

So when saving the value you need to mimic the original array format. I would share what that is for your example, but it cannot be unserialized because it has been corrupted by editing the value by hand.

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.