Menu predefinito di Wordpress nel database
1 risposta
- voti
-
- 2013-01-05
Ilmenu diper sé è unatassonomiain WP. Significa chepuoitrovaretuttii menunellatabella
wp_terms
,eseguendo la seguente query:SELEZIONA * DA wp_terms ASt SINISTRA UNISCITI wp_term_taxonomy AStt ONtt.term_id=t.term_id WHEREtt.taxonomy='nav_menu';
La voce dimenu è untipo dipostpersonalizzatoin WP. Sono archiviatinellatabella
wp_posts
. Puoitrovarlitutti utilizzando questa query:SELEZIONA * FROM wp_posts WHEREpost_type='nav_menu_item';
Le relazionitrai menue le voci dimenu sonomemorizzatenellatabella
wp_term_relationships
. Pertrovaretuttiglielementi di unmenu specificopuoi utilizzare questa query:SELEZIONAp. * DA wp_posts ASp LEFT JOIN wp_term_relationships AStr ONtr.object_id=p.ID SINISTRA UNISCITI wp_term_taxonomy AStt ONtt.term_taxonomy_id=tr.term_taxonomy_id WHEREp.post_type='nav_menu_item' ANDtt.term_id=/*iltuo IDmenu */; Leinformazioni sulmenu attualmente selezionato sitrovanonellatabella
wp_options
come array PHP serializzato. Adesempio,se utilizziamoiltema TwentyEleven,avremo un recordnellatabellawp_options
con la colonnaoption_name
uguale atheme_mod_twentyeleven
eoption_value < La colonna/code> è uguale a
...; s: 18: "nav_menu_locations"; a: 1: {s: 7: "primary";i: 103;}}
. Quipuoi vedere cheilmenu conterm_id
uguale a 103 è attualmente selezionato comemenu"primario"
.Ilprincipio chiave qui è che abbiamo sempre record di opzioni separatiper ognitema WP. Tali opzioni hanno la stessa struttura delnome:
theme_mods_ {nome-tema}
.P.S .: Per cambiareilmenu correntenelpannello di amministrazione,vai su
Aspetto
& raquo;Menu
e selezionailmenu di cui haibisognonelmetaboxTheme Locations
: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 inwp_options
table withoption_name
column equals totheme_mod_twentyeleven
andoption_value
column equals to...;s:18:"nav_menu_locations";a:1:{s:7:"primary";i:103;}}
. Here you can see that menu withterm_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 inTheme Locations
meta box:-
Grazieper latua rispostama Voglio sapere dovememorizzailmenu che èpredefinito (mostrato alfront-end) ora.Thanks for your reply but I want to know where it stores the menu which is default (showing to front end) now.
- 0
- 2013-01-05
- Hiren Rathod
-
@HirenRathod Ho aggiornato lamia risposta@HirenRathod I have updated my answer
- 0
- 2013-01-05
- Eugene Manuilov
-
Sì,ho la risposta.Sto usandoiltema hypershote homantenutoilmenuprincipale comemenu diprova. Memorizzain questomodo a: 2: {i: 0;b: 0; s: 18: "posizioni_menu_avv"; a: 2: {s: 11: "menu-intestazione";i: 27; s: 11: "menu-piè dipagina";i: 0;}} Quii: 27 significa che 27 èilterm_id di wp_terms. Grazie @eugene-manuilov :)Yes, I got the answer. I'm using hypershot theme and kept primery menu as test menu. It stores like this a:2:{i:0;b:0;s:18:"nav_menu_locations";a:2:{s:11:"header-menu";i:27;s:11:"footer-menu";i:0;}} Here i:27 means 27 is the term_id from wp_terms. Thanks @eugene-manuilov :)
- 0
- 2013-01-06
- Hiren Rathod
-
Come selezionereste le voci dimenu (pagine/post/link)per un dato `term_id`?How would you select the menu items (pages/posts/links) for a given `term_id`?
- 0
- 2015-09-19
- Xeoncross
Ci sono 3menunelmio wordpress (3.5) ora.
Ora homantenutoilmenu diprova comepredefinito.
Dovememorizza Wordpress questa cosa?
Voglio sapere dove wordpressmemorizzailmenu corrente visualizzatonelfront-end.