WordPress database schema – what tables does WordPress use?

Last updated December 6th, 2023 06:07

A fresh installation of WordPress creates a number of tables in a MySQL database. The specific table names may vary slightly depending on the prefix used during the installation process, but the default prefix is “wp_”. So take a look on WordPress database schema – what tables does WordPress use?

WordPress database schema – what tables does WordPress use?

Here are the default tables created in a new WordPress installation:

  • wp_commentmeta
  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy
  • wp_usermeta
  • wp_users

Now let’s take a closer look at what these 11 tables in MySQL are used for.

WordPress database schema – what tables does WordPress use?

wp_commentmeta

WordPress uses the wp_commentmeta table in MySQL to store metadata for comments posted on the site.

The wp_comments table stores the basic information about a comment, such as the comment author, email, and content. However, there may be additional information that needs to be associated with a comment, such as a specific rating or feedback data.

To store this additional information, WordPress uses the wp_commentmeta table. This table has a simple structure, with just four columns:

  • meta_id: A unique identifier for each metadata entry.
  • comment_id: The ID of the comment that the metadata is associated with.
  • meta_key: The name of the metadata field.
  • meta_value: The value of the metadata field.

By default, WordPress does not use any specific metadata fields for comments. However, plugins or themes can use this table to store their own metadata for comments, which can be used for various purposes such as rating, feedback or moderation.

wp_comments

WordPress uses the wp_comments table in MySQL to store comments that are posted on the site.

The wp_comments table has a simple structure with the following columns:

  • comment_ID: A unique identifier for each comment.
  • comment_post_ID: The ID of the post that the comment is associated with.
  • comment_author: The name of the person who posted the comment.
  • comment_author_email: The email address of the person who posted the comment.
  • comment_author_url: The URL of the website of the person who posted the comment.
  • comment_author_IP: The IP address of the person who posted the comment.
  • comment_date: The date and time that the comment was posted.
  • comment_date_gmt: The GMT date and time that the comment was posted.
  • comment_content: The content of the comment.
  • comment_approved: Whether the comment is approved or not. The default value is “1” for approved comments and “0” for unapproved comments.
  • comment_agent: The user agent string of the person who posted the comment.
  • comment_type: The type of the comment, such as “comment”, “pingback”, or “trackback”.
  • comment_parent: The ID of the parent comment if this comment is a reply to another comment.

WordPress uses this table to store all the basic information related to comments on posts or pages on the site. The comments are used to facilitate discussion and engagement with the content of the site.

wp_links

WordPress uses the wp_links table in MySQL to store information about links or URLs. This table is also referred to as the “Links Manager”.

The wp_links table has a simple structure with the following columns:

  • link_id: A unique identifier for each link.
  • link_url: The URL of the link.
  • link_name: The name or title of the link.
  • link_image: The URL of an image associated with the link.
  • link_target: The target attribute of the link. This can be “_blank” for opening the link in a new window, “_self” for opening the link in the same window, or other values.
  • link_description: A description of the link.
  • link_visible: Whether the link is visible or not. The default value is “Y” for visible links and “N” for hidden links.
  • link_owner: The ID of the user who added the link.
  • link_rating: The rating or popularity of the link.
  • link_updated: The date and time that the link was last updated.
  • link_rel: The relationship of the link with the current page.
  • link_notes: Any notes associated with the link.
  • link_rss: The URL of an RSS or Atom feed associated with the link.

WordPress uses this table to manage the links that appear on the site. The links can be added to the site through the “Links” or “Blogroll” section in the WordPress dashboard. The links can be used to provide additional resources or references for readers or to support partnerships with other sites. However, since WordPress 3.5, the “Links Manager” functionality was removed from the core, and replaced by external plugins.

wp_options

WordPress uses the wp_options table in MySQL to store various options and settings for the site.

The wp_options table has a simple structure with the following columns:

  • option_id: A unique identifier for each option.
  • option_name: The name of the option.
  • option_value: The value of the option.
  • autoload: Whether the option should be loaded automatically or not. The default value is “yes” for autoloaded options and “no” for non-autoloaded options.

WordPress uses this table to store various settings and configurations for the site, including:

  • Site title and description
  • Permalink structure
  • Default post and page categories
  • WordPress version
  • Date and time format
  • Timezone
  • Active theme and plugin list
  • Site language
  • Database version
  • And many other settings

WordPress retrieves and saves options in this table using functions such as get_option() and update_option(). Plugins and themes can also use this table to store their own settings or configurations. The wp_options table is a key component of the WordPress database and plays an important role in the overall functioning of the site.

wp_postmeta

WordPress uses the wp_postmeta table in MySQL to store additional metadata for posts and pages on the site.

The wp_postmeta table has a simple structure with the following columns:

  • meta_id: A unique identifier for each metadata entry.
  • post_id: The ID of the post or page that the metadata is associated with.
  • meta_key: The name of the metadata field.
  • meta_value: The value of the metadata field.

By default, WordPress uses several metadata fields for posts and pages, including:

  • _edit_lock: Stores a timestamp and user ID to indicate who is currently editing the post.
  • _edit_last: Stores the user ID of the last person to edit the post.
  • _thumbnail_id: Stores the ID of the featured image for the post.
  • _wp_page_template: Stores the name of the template file used to display the page.
  • _wp_attached_file: Stores the file path of an uploaded image.
  • _wp_attachment_metadata: Stores metadata about an uploaded image, such as its size and dimensions.

Plugins and themes can also use the wp_postmeta table to store their own metadata for posts and pages. This metadata can be used for various purposes, such as custom fields, additional data for SEO, or for custom post types.

Overall, the wp_postmeta table is an important part of the WordPress database, allowing developers and site owners to store additional data for posts and pages beyond the standard fields provided by WordPress.

wp_posts

The wp_posts table is one of the core tables in WordPress and is used to store all posts, pages, and other custom post types on the site.

The wp_posts table has a simple structure with the following columns:

  • ID: A unique identifier for each post.
  • post_author: The ID of the user who created the post.
  • post_date: The date and time that the post was created.
  • post_date_gmt: The GMT date and time that the post was created.
  • post_content: The content of the post in HTML format.
  • post_title: The title of the post.
  • post_excerpt: A short description or summary of the post.
  • post_status: The status of the post, such as “published”, “draft”, or “pending”.
  • comment_status: The comment status of the post, such as “open” or “closed”.
  • ping_status: The pingback and trackback status of the post, such as “open” or “closed”.
  • post_password: A password to protect the post.
  • post_name: The slug or URL-friendly version of the post title.
  • to_ping: URLs to be pinged when the post is published.
  • pinged: URLs that have already been pinged for the post.
  • post_modified: The date and time that the post was last modified.
  • post_modified_gmt: The GMT date and time that the post was last modified.
  • post_content_filtered: The filtered version of the post content.
  • post_parent: The ID of the parent post, if the current post is a child post.
  • guid: The globally unique identifier for the post.
  • menu_order: The order of the post in the menu.
  • post_type: The type of the post, such as “post”, “page”, or a custom post type.
  • post_mime_type: The MIME type of the post attachment.
  • comment_count: The number of comments on the post.

WordPress uses this table to store all content on the site, including blog posts, pages, and other custom post types. When a post is created or edited, WordPress saves the relevant data to this table. This table also stores information related to post revisions, such as the date and time of the revision and the user who made the revision.

Overall, the wp_posts table is one of the most important tables in the WordPress database, as it stores the content that makes up the majority of the site.

wp_terms

WordPress uses the wp_terms table in MySQL to store the categories and tags used on the site.

The wp_terms table has a simple structure with the following columns:

  • term_id: A unique identifier for each term.
  • name: The name of the term.
  • slug: The slug or URL-friendly version of the term name.
  • term_group: The group ID of the term.

WordPress uses this table to store all the categories and tags used on the site. Categories and tags are used to organize posts and pages on the site, making it easier for users to find related content.

When a category or tag is created, WordPress saves the relevant data to this table. WordPress also uses the wp_term_taxonomy table to associate each term with a specific taxonomy, such as “category” or “post_tag”.

In addition to the default “category” and “post_tag” taxonomies, plugins and themes can create custom taxonomies for organizing content. When a custom taxonomy is created, WordPress also creates a new table in the database to store the terms for that taxonomy.

Overall, the wp_terms table is an important part of the WordPress database, allowing developers and site owners to organize their content using categories and tags.

wp_term_relationships

The wp_term_relationships table is used by WordPress to associate posts and other content with categories, tags, and other taxonomies. It is used to create a many-to-many relationship between posts and their associated terms.

The wp_term_relationships table has a simple structure with the following columns:

  • object_id: The ID of the post or content item.
  • term_taxonomy_id: The ID of the term taxonomy for the associated term.
  • term_order: The order in which the associated term is displayed.

When a post or content item is associated with a term (such as a category or tag), WordPress creates a new row in the wp_term_relationships table. The object_id column contains the ID of the post or content item, and the term_taxonomy_id column contains the ID of the term taxonomy for the associated term. The term_order column is used to specify the order in which the associated term is displayed.

WordPress uses this table to enable users to browse content by category or tag, and to display related content on the site. For example, when a user clicks on a category or tag on a post, WordPress uses the wp_term_relationships table to find other posts that are associated with the same term and displays them to the user.

Overall, the wp_term_relationships table is an important part of the WordPress database, allowing users to organize their content and enabling WordPress to display related content on the site.

wp_term_taxonomy

The wp_term_taxonomy table in MySQL is used by WordPress to store information about taxonomies and their associated terms. It provides a way to group related terms together and to specify how they are displayed on the site.

The wp_term_taxonomy table has the following columns:

  • term_taxonomy_id: A unique identifier for each taxonomy term.
  • term_id: The ID of the term being described.
  • taxonomy: The name of the taxonomy to which the term belongs (e.g., “category” or “post_tag”).
  • description: A description of the taxonomy.
  • parent: The ID of the parent term, if any.
  • count: The number of times the term has been used.

When a new taxonomy (such as a custom category or tag) is created in WordPress, a new row is added to the wp_term_taxonomy table. This row specifies the name and description of the taxonomy, as well as any parent-child relationships between terms in the taxonomy. Each term in the taxonomy is assigned a unique ID and added to the wp_terms table, with a reference to the appropriate row in wp_term_taxonomy.

WordPress uses the wp_term_taxonomy table to organize and display content on the site. For example, when a user clicks on a category or tag on a post, WordPress uses the wp_term_relationships table to find other posts that are associated with the same term, and then uses the wp_term_taxonomy table to display the associated terms and their descriptions.

Overall, the wp_term_taxonomy table is an important part of the WordPress database, allowing users to organize their content and enabling WordPress to display related content on the site.

wp_usermeta

The wp_usermeta table in MySQL is used by WordPress to store additional user metadata beyond the basic user information stored in the wp_users table. This table allows developers and site owners to store custom user data and metadata that is specific to their site.

The wp_usermeta table has a simple structure with the following columns:

  • umeta_id: A unique identifier for each user metadata item.
  • user_id: The ID of the user to whom the metadata item belongs.
  • meta_key: The name of the metadata item.
  • meta_value: The value of the metadata item.

WordPress uses the wp_usermeta table to store additional information about users, such as their preferences, profile information, and other custom data. This can include things like social media links, user roles and permissions, and other information that is specific to the site.

When a new metadata item is added for a user, WordPress creates a new row in the wp_usermeta table, with a reference to the user’s ID in the user_id column. The meta_key column specifies the name of the metadata item, and the meta_value column contains the value of the metadata item.

Overall, the wp_usermeta table is an important part of the WordPress database, allowing developers and site owners to store custom user data and metadata that is specific to their site.

wp_users

The wp_users table in MySQL is used by WordPress to store basic information about registered users of a site. It is a core table of the WordPress database, and it stores information such as user names, email addresses, passwords, and other basic user information.

The wp_users table has a simple structure with the following columns:

  • ID: A unique identifier for each user.
  • user_login: The user’s login name.
  • user_pass: The user’s password, encrypted for security.
  • user_nicename: A user-friendly name for the user.
  • user_email: The user’s email address.
  • user_url: The user’s website URL.
  • user_registered: The date and time the user was registered on the site.
  • user_activation_key: A key used for account activation, if necessary.
  • user_status: The status of the user’s account (e.g., active, inactive, deleted).

WordPress uses the wp_users table to manage user accounts on the site. When a user registers on the site, a new row is added to the wp_users table with their basic information. The user’s password is encrypted for security purposes.

WordPress uses the wp_users table to authenticate users when they log in to the site. When a user enters their login name and password, WordPress checks the wp_users table to verify that the user exists and that the password is correct.

Overall, the wp_users table is an important part of the WordPress database, providing the basic information needed to manage user accounts and authenticate users on the site.

WordPress database schema – what tables does WordPress use? Schema of MySQL tables.

Diagram tabulek MySQL WordPressu a jejich závislostí

More content about WordPress

Whole category is here

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.

newsletter

Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Odebírat
Upozornit na
guest
0 Komentáře/ů
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje