Where are custom types stored? Because when a custom type is created, in wp_posts, the post type is set to the <new_custom_post_type>
. But where are the details of the new custom post type stored??
Leave a Reply
You must be logged in to post a comment.
I finally found the custom post type data. It is stored in the wp_post table where post_type = custom post type (e.g. “products”). The field (column) data is stored in wp_postmeta where the meta_key is the column name and meta_value is the column value.
This query will bring back all data associated with the custom post type “products”:
The details of custom post types aren’t stored anywhere, they’re loaded at runtime with each request via
register_post_type
calls.As mentioned by @milo in this answer
Post Types aren’t actually stored separately in the database however that being said…
via SQL
you can view all saved PUBLIC post types using the following sql query
Which will output something similar to:
via WP CLI
Additionally if you have access to wp cli, you can run:
Which will output something like:
You can use the function
get_post_types
to get information on any and all post types that are active at that time. To get info on a specific post type, useget_post_type_object
.WordPress default comes with some sample post types like pages, posts etc. WordPress has given option to create our own custom post types also. Both default & custom posts are stored in single table “wp_posts” by differentiating all posts types based on “post_type” column in “wp_posts” table.
Eg:
pages–> post_type=”page”,
testiminials–> post_type=”testimonials”
etc
To grab more information about this post_types, which would be available at “wp_postmeta ” table.