I just got my hand into wordpress and wp theme development.

I know to create basic wordpress themes from scratch but I wondered how to get into custom theme options. My custom theme options (custom fields) are working fine but the problem is that I've heard (not really read it!) that the values are stored into the wordpress's options table and its retrieved from there.

When I take a look into that table via phpmyadmin, I can't find my custom values. Everything is working fine, but I can't find it into my database.

I am using the latest version of Wordpress

1 Answer 1


There is indeed an options table (wp_options / prefix_options). You can the find full details on that table here: http://codex.wordpress.org/Database_Description#Table:_wp_options

Options are meant to be globally accessible (not tied to individual posts), and you only need to know the option name/key. You can access that table and its values with the following functions:

<?php $your_option = get_option( $option, $default ); ?> - http://codex.wordpress.org/Function_Reference/get_option

<?php update_option( $option, $new_value ); ?> - http://codex.wordpress.org/Function_Reference/update_option

Now you mentioned custom fields, this is something completely different. Custom fields are tied to individual posts and are stored in the wp_postmeta (or prefix_postmeta) table. To access this data you'll need both the post_id and the custom field name/key.

(Full details on the _postmeta table here: http://codex.wordpress.org/Database_Description#Table:_wp_postmeta)

You can access these values with the following functions:

<?php $meta_values = get_post_meta( $post_id, $key, $single ); ?> - http://codex.wordpress.org/Function_Reference/get_post_meta

<?php add_post_meta($post_id, $meta_key, $meta_value, $unique); ?> - http://codex.wordpress.org/Function_Reference/add_post_meta

<?php update_post_meta($post_id, $meta_key, $meta_value, $prev_value); ?> - http://codex.wordpress.org/Function_Reference/update_post_meta

<?php delete_post_meta($post_id, $meta_key, $meta_value); ?> - http://codex.wordpress.org/Function_Reference/delete_post_meta

There are more, and you can find them in the CODEX.

  • well, i am sorry for using the wrong name(custom fields)... Nov 15, 2014 at 18:15
  • all that i am trying to do is to create some theme options and i did it, for example i can add some custom text and i am able to retrieve it from the database using the get_option(); function but i can't find those values in the database, whenever i go to wp_option table there are only defaults which are created by wordpress! Nov 15, 2014 at 18:18
  • ok, thanks, that was my own mistake, i just ran a search query through the database and the problem is that i had to get to the last page LOL, i was looking at first 25 search results... Nov 15, 2014 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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