Les commandes WP CLI pour les menus.

Gestion de vos menus WordPress avec WP CLI, on vous liste les commandes dans cette page.

Gérer les emplacement de menu

BASH
                    # Assigner un menu à un emplacement
# wp menu location assign {menu} {location}
wp menu location assign main-menu main

# Lister les emplacements
wp menu location list

# Supprimer le menu d'un emplacement
# wp menu location remove {menu} {location}
wp menu location remove main-menu main
                

Lister les menus

BASH
                    wp menu list 
                

Gérer les items du menu

BASH
                    ## Ajouter des items
# Ajouter un post existant
# wp menu item add-post {menu_slug} {post_id} --title={menu_title}
wp menu item add-post main-menu 1337 --title="Custom menu title"

# Ajouter un lien personnalisé
# wp menu item add-post {menu_slug} {menu_title} {menu_link}
wp menu item add-custom main-menu "Custom title" "https://custom-link.com"

# Ajouter un terme de taxonomie
# wp menu item add-term {menu_slug} {taxonomy} {term_id}
wp menu item add-term main-menu post_tag 1337

## Supprimer des items
# wp menu item delete {item_id}
wp menu item delete 1337

## Lister les items d'un menu
# wp menu item list {menu_slug}
wp menu item list main-menu

## Modifier un item de menu
# wp menu item update {item_id} --title={item_title} --link={item_link} --target={target} --position={position}
wp menu item update 1337 --title=WordPress --link='http://wordpress.org' --target=_blank --position=2
                

Supprimer un menu

BASH
                    # wp menu delete {menu_name|menu_slug|menu_term_ID}
wp menu delete "Main Menu"
                

Créer un menu

BASH
                    # wp menu create {menu_name}
wp menu create "Main Menu"