• Trang chủ
  • Khóa học
  • Bài viết
  • Giới thiệu
  • Liên hệ
  • Github
  • Shop Cún yêu
    • RegisterLogin
      • GET STARTED
    Nền tảng Kiến thứcNền tảng Kiến thức
    • Trang chủ
    • Khóa học
    • Bài viết
    • Giới thiệu
    • Liên hệ
    • Github
    • Shop Cún yêu
    • RegisterLogin
      • GET STARTED

      Hướng dẫn

      • Home
      • Blog
      • Hướng dẫn
      • Where to find menus in wordpress database

      Where to find menus in wordpress database

      • Posted by Dương Nguyễn Phú Cường
      • Categories Hướng dẫn, Wordpress
      • Date 18/11/2019

      Where to find menus in wordpress database

      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';

      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';

      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*/;

      Information about currently select menu is located in wp_options table as serialized PHP array. For example if we use TwentyEleven theme, then we will have a record in wp_options table with option_name column equals to theme_mod_twentyeleven and option_value column equals to ...;s:18:"nav_menu_locations";a:1:{s:7:"primary";i:103;}}. Here you can see that menu with term_id equals to 103 is currently selected as "primary" menu.

      The key principle here is that we always have separate options record for each WP theme. Such options have the same name structure: theme_mods_{your-theme-name}.

      P.S.: To change current menu in the admin panel, just go to Appearance » Menus page and select menu you need in Theme Locations meta box:

      enter image description here

       

       

      Source: Eugene Manuilov

      on stackoverflow

       

      Notes from me ( digitalzoomstudio )

      Okay, this is correct, but incomplete; missing a few key items. For example, the pages / posts on which each item is stored. When trying to create a menu from php, this info is not enough because we need to link each post ( nav_menu_item type ) to page’s link.

      This info is found in wp_postmeta table, containing info of each menu item – like nav_menu_item type ( custom / page ) or custom link etc. :

      meta_id, post_id, option_name

      1233 208 _menu_item_url
      1232 208 _menu_item_xfn
      1231 208 _menu_item_classes a:1:{i:0;s:0:””;}
      1230 208 _menu_item_target
      1229 208 _menu_item_object page
      1228 208 _menu_item_object_id 179
      1227 208 _menu_item_menu_item_parent 0
      1226 208 _menu_item_type post_type
      • Share:
      author avatar
      Dương Nguyễn Phú Cường
      Code with my love

      Previous post

      Đánh giá chất lượng SSL
      18/11/2019

      Next post

      Các câu lệnh GIT thông dụng
      25/11/2019

      You may also like

      Speedup WordPress
      28 Tháng Mười Một, 2019

      https://onlinemediamasters.com/slow-wordpress-admin-panel/

      Nén ảnh
      25 Tháng Mười Một, 2019

      https://stackoverflow.com/questions/7261855/recommendation-for-compressing-jpg-files-with-imagemagick

      Đánh giá chất lượng SSL
      17 Tháng Mười Một, 2019

      Sử dụng link sau để test chất lượng SSL https://www.ssllabs.com/ssltest/analyze.html?d=nentang.vn&latest

      Search

      Chuyên mục

      • Blog
      • Business
      • Chưa phân loại
      • Design / Branding
      • Đăng ký Khóa học
      • Facebook
      • Hướng dẫn
      • Kho sách
      • Lập trình
      • Lập trình Web
      • Laravel
      • Phần mềm Quay số
      • Phong cách thiết kế Web
      • Photoshop
      • Tài liệu hướng dẫn
      • Tạo Khóa học
      • Thanh toán Online
      • Triển khai web
      • Whitehat Hacker
      • Wordpress

      Latest Courses

      Thiết kế web với framework Laravel

      Thiết kế web với framework Laravel

      Miễn phí
      Lập trình căn bản C#

      Lập trình căn bản C#

      Miễn phí
      Lập trình căn bản PHP

      Lập trình căn bản PHP

      Miễn phí

      Sign up for Newsletter

      Be one step ahead with our latest deals, offers and discount for Education themes

      Liên hệ

      • admin@nentang.vn
      • (+84) 915659223
      • 130 Xô Viết Nghệ Tỉnh, Quận Ninh Kiều, TP Cần Thơ

      Company

      • About Us
      • Blog
      • Contact
      • Become a Teacher

      Useful Links

      • Courses
      • Events
      • Gallery
      • FAQs

      Support

      • Documentation
      • Forums
      • Language Packs
      • Release Status

      Mobile

      Nền tảng trên Đi động

      • Home
      • Courses

        About Courses

        • Courses Archive
        • Become an Instructor
        • Instructor Profile
        Thiết kế web với Bootstrap

        Thiết kế web với Bootstrap

        Miễn phí
        Read More
      • Features
        • Gallery
        • Portfolio
        • About Us
        • FAQs
      • Events
      • Blog
      • Contact
      • Shop

      Bản quyền bởi © NenTang.vn

      • Privacy
      • Terms
      • Sitemap

      Login with your site account

      Lost your password?

      Not a member yet? Register now

      Register a new account

      Are you a member? Login now