On this page
- 1 WordPress: Post Types
- 2 WordPress: Post Types
- 2.1 Post Types
- 2.1.0.1 Metadata in WordPress
- 2.1.0.2 WP_List_Table tutorial : How to display data from database to the admin block ?
- 2.1.0.3 Shortcode in WordPress
- 2.1.0.4 Add Tracking Code in WordPress
- 2.1.0.5 Creating an Administrator Account in WordPress Using Custom PHP Code
- 2.1.0.6 WordPress: Plugins
- 2.1.0.7 WordPress: Hooks
- 2.1.0.8 Cheatsheet: WordPress
- 2.1.0.9 WordPress: Important Functions
- 2.2 Leave A Comment Cancel reply
- 2.1 Post Types
WordPress: Post Types
WordPress: Post Types
February 12, 2021
Post Types
There are five default Post Types readily available to users or internally used by the WordPress installation:
- Post (Post Type: ‘post’)
- Page (Post Type: ‘page’)
- Attachment (Post Type: ‘attachment’)
- Revision (Post Type: ‘revision’)
- Navigation menu (Post Type: ‘nav_menu_item’)
Menu item is custom post type in WP. They are stored in wp_posts table. You can find all of them by using this query:
SELECT * FROM `wp_posts` WHERE post_type = 'nav_menu_item'
Menu by itself is a taxonomy in WP. It means that you can find all menus in wp_terms table, by running following query:
SELECT * FROM wp_terms AS t LEFT JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id WHERE tt.taxonomy = 'nav_menu'
Relations between menus and menu items are stored in wp_term_relationships table. To find all items of specific menu you can use this query:
SELECT p.* FROM wp_posts AS p LEFT JOIN wp_term_relationships AS tr ON tr.object_id = p.ID LEFT JOIN wp_term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id WHERE p.post_type = 'nav_menu_item' AND tt.term_id = /*your menu ID*/;