Skip to content
- wp_postmeta – Used for both posts AND pages. This is where custom fields attached to a post/page would store their data.
- wp_posts – All content types are kept in the wp_posts table and are distinguished from one another by a post type. Default post types are post, page, attachment, revision, and navigation menu.
- Navigation Menu – nav_menu_item – This is not an entire menu but a single navigational item on a larger menu.
- wp_terms – For the taxonomy system, contains categories, tags, and custom taxonomies.
- wp_term_relationships – When terms are hierarchical the relationship between one term and another is stored here. This table is being merged into wp_terms in the future.
- wp_term_taxonomy – Used to determine which terms are actually the root level of a taxonomy.
Methods for Saving Data to Database
- Option Mechanism – For small amounts of data that rarely changes.
- Best practice is to use as few as possible, consider including multiple values in a single option field.
- add_option($name, $value, $deprecated, $autoload);
- Only creates if it doesn’t already exist
- $(option_)name = name of option; $value = default value (optional); $deprecated = no longer used, pass an empty string or null to it if you want to use $autoload; $autoload = should option be loaded by wp_load_alloptions function? by default is yes.
- Retrieve the option from DB.
- update_option($option_name, $newvalue);
- Can be used to create an option if the deprecated or autoload params are not needed.
- Post Meta
- Pulled into multi-dimensional array $post_meta_cache after $posts in wp-blog-header.php