Toggle navigation
Hot Examples
FR
EN
RU
DE
FR
ES
PT
IT
JP
ZH
KO
PHP
PHP
C#
Java
Go
C++
Python
JS
TS
Rechercher
Accueil
Menu_Item_Command
PHP Class Menu_Item_Command, wp-cli
## EXAMPLES # Add an existing post to an existing menu $ wp menu item add-post sidebar-menu 33 --title="Custom Test Post" Success: Menu item added. # Create a new menu link item $ wp menu item add-custom sidebar-menu Apple http://apple.com Success: Menu item added. # Delete menu item $ wp menu item delete 45 Success: 1 menu item deleted.
Inheritance:
extends
WP_CLI_Command
Afficher le fichier
Open project: wp-cli/wp-cli
Protected Properties
Свойство
Type
Description
$obj_fields
Méthodes publiques
Méthode
Description
add_custom
(
$args
,
$assoc_args
)
Add a custom menu item.
add_post
(
$args
,
$assoc_args
)
Add a post as a menu item.
add_term
(
$args
,
$assoc_args
)
Add a taxonomy term as a menu item.
delete
(
$args
,
$_
)
Delete one or more items from a menu.
list_
(
$args
,
$assoc_args
)
Get a list of items associated with a menu.
update
(
$args
,
$assoc_args
)
Update a menu item.
Méthodes protégées
Méthode
Description
get_formatter
( &
$assoc_args
)
Private Methods
Méthode
Description
add_or_update_item
(
$method
,
$type
,
$args
,
$assoc_args
)
Worker method to create new items or update existing ones.
Method Details
add_custom()
public
méthode
## OPTIONS
: The name, slug, or term ID for the menu.
: Title for the link. <link> : Target URL for the link. [--description=<description>] : Set a custom description for the menu item. [--attr-title=<attr-title>] : Set a custom title attribute for the menu item. [--target=<target>] : Set a custom link target for the menu item. [--classes=<classes>] : Set a custom link classes for the menu item. [--position=<position>] : Specify the position of this menu item. [--parent-id=<parent-id>] : Make this menu item a child of another menu item. [--porcelain] : Output just the new menu item id. ## EXAMPLES $ wp menu item add-custom sidebar-menu Apple http://apple.com Success: Menu item added. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-add_custom">add_custom</a></span> ( <span class="param-name">$args</span>, <span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-add_post"> <div class="row"> <div class="col-md-6"> <h3> add_post() <span class="modifier">public</span > <span>méthode</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/fr/method/-/Menu_Item_Command/add_post/-" rel="nofollow" title="Source code of method Menu_Item_Command::add_post"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-add_post" title="Direct link to the method Menu_Item_Command::add_post documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <menu> : The name, slug, or term ID for the menu. <post-id> : Post ID to add to the menu. [--title=<title>] : Set a custom title for the menu item. [--link=<link>] : Set a custom url for the menu item. [--description=<description>] : Set a custom description for the menu item. [--attr-title=<attr-title>] : Set a custom title attribute for the menu item. [--target=<target>] : Set a custom link target for the menu item. [--classes=<classes>] : Set a custom link classes for the menu item. [--position=<position>] : Specify the position of this menu item. [--parent-id=<parent-id>] : Make this menu item a child of another menu item. [--porcelain] : Output just the new menu item id. ## EXAMPLES $ wp menu item add-post sidebar-menu 33 --title="Custom Test Post" Success: Menu item added. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-add_post">add_post</a></span> ( <span class="param-name">$args</span>, <span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-add_term"> <div class="row"> <div class="col-md-6"> <h3> add_term() <span class="modifier">public</span > <span>méthode</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/fr/method/-/Menu_Item_Command/add_term/-" rel="nofollow" title="Source code of method Menu_Item_Command::add_term"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-add_term" title="Direct link to the method Menu_Item_Command::add_term documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <menu> : The name, slug, or term ID for the menu. <taxonomy> : Taxonomy of the term to be added. <term-id> : Term ID of the term to be added. [--title=<title>] : Set a custom title for the menu item. [--link=<link>] : Set a custom url for the menu item. [--description=<description>] : Set a custom description for the menu item. [--attr-title=<attr-title>] : Set a custom title attribute for the menu item. [--target=<target>] : Set a custom link target for the menu item. [--classes=<classes>] : Set a custom link classes for the menu item. [--position=<position>] : Specify the position of this menu item. [--parent-id=<parent-id>] : Make this menu item a child of another menu item. [--porcelain] : Output just the new menu item id. ## EXAMPLES $ wp menu item add-term sidebar-menu post_tag 24 Success: Menu item added. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-add_term">add_term</a></span> ( <span class="param-name">$args</span>, <span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-delete"> <div class="row"> <div class="col-md-6"> <h3> delete() <span class="modifier">public</span > <span>méthode</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/fr/method/-/Menu_Item_Command/delete/-" rel="nofollow" title="Source code of method Menu_Item_Command::delete"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-delete" title="Direct link to the method Menu_Item_Command::delete documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <db-id>... : Database ID for the menu item(s). ## EXAMPLES $ wp menu item delete 45 Success: 1 menu item deleted. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-delete">delete</a></span> ( <span class="param-name">$args</span>, <span class="param-name">$_</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-get_formatter"> <div class="row"> <div class="col-md-6"> <h3> get_formatter() <span class="modifier">protected</span > <span>méthode</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/fr/method/-/Menu_Item_Command/get_formatter/-" rel="nofollow" title="Source code of method Menu_Item_Command::get_formatter"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-get_formatter" title="Direct link to the method Menu_Item_Command::get_formatter documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> </div> </div> <div class="row doc-tags"> <div class="col-md-12"> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">protected</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-get_formatter">get_formatter</a></span> ( &<span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-list_"> <div class="row"> <div class="col-md-6"> <h3> list_() <span class="modifier">public</span > <span>méthode</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/fr/method/-/Menu_Item_Command/list_/-" rel="nofollow" title="Source code of method Menu_Item_Command::list_"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-list_" title="Direct link to the method Menu_Item_Command::list_ documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <menu> : The name, slug, or term ID for the menu. [--fields=<fields>] : Limit the output to specific object fields. [--format=<format>] : Render output in a particular format. --- default: table options: - table - csv - json - count - ids - yaml --- ## AVAILABLE FIELDS These fields will be displayed by default for each menu item: * db_id * type * title * link * position These fields are optionally available: * menu_item_parent * object_id * object * type * type_label * target * attr_title * description * classes * xfn ## EXAMPLES $ wp menu item list main-menu +-------+-----------+-------------+---------------------------------+----------+ | db_id | type | title | link | position | +-------+-----------+-------------+---------------------------------+----------+ | 5 | custom | Home | http://example.com | 1 | | 6 | post_type | Sample Page | http://example.com/sample-page/ | 2 | +-------+-----------+-------------+---------------------------------+----------+ </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-list_">list_</a></span> ( <span class="param-name">$args</span>, <span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-update"> <div class="row"> <div class="col-md-6"> <h3> update() <span class="modifier">public</span > <span>méthode</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/fr/method/-/Menu_Item_Command/update/-" rel="nofollow" title="Source code of method Menu_Item_Command::update"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-update" title="Direct link to the method Menu_Item_Command::update documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <db-id> : Database ID for the menu item. [--title=<title>] : Set a custom title for the menu item. [--link=<link>] : Set a custom url for the menu item. [--description=<description>] : Set a custom description for the menu item. [--attr-title=<attr-title>] : Set a custom title attribute for the menu item. [--target=<target>] : Set a custom link target for the menu item. [--classes=<classes>] : Set a custom link classes for the menu item. [--position=<position>] : Specify the position of this menu item. [--parent-id=<parent-id>] : Make this menu item a child of another menu item. ## EXAMPLES $ wp menu item update 45 --title=WordPress --link='http://wordpress.org' --target=_blank --position=2 Success: Menu item updated. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#method-update">update</a></span> ( <span class="param-name">$args</span>, <span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <h2>Property Details</h2> <div class="property-descr-full" id="prop-obj_fields"> <div class="row"> <div class="col-md-6"> <h3 class="name">$obj_fields <span>protected_oe property</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command#prop-obj_fields" title="Direct link to property Menu_Item_Command::obj_fields documentation"> <i class='icon-borderless icon-link'></i> </a> </div> </div> <div class="row"> <div class="col-md-12"> </div> </div> <div class="row doc-tags"> <div class="col-md-12"> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <!-- <tr> <td colspan="3"></td> </tr> --> <tr> <td colspan="3" class="rendered"> <span class="modifier">protected</span > <span class="var-name">$obj_fields</span> </td> </tr> </table> </div> </div> </div> </div> </div> </div></div> <footer class="footer"> <div class="container"> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/fr/site/trends?type=php%7Cf">Fonctions les mieux classées</a> | <a href="https://hotexamples.com/fr/site/trends?type=php%7Cc"> Classes les mieux classées </a> | <a href="https://doc.hotexamples.com/fr/doc/map">Documentation</a> | <a href="/site/privacy">Politique de confidentialité</a> | <a href="https://cpp.hotexamples.com/direct-sales.html">Advertise with us</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/fr/">PHP</a> | <a href="https://csharp.hotexamples.com/fr/">C# (CSharp)</a> | <a href="https://java.hotexamples.com/fr/">Java</a> | <a href="https://golang.hotexamples.com/fr/">Golang</a> | <a href="https://cpp.hotexamples.com/fr/">C++ (Cpp)</a> | <a href="https://python.hotexamples.com/fr/">Python</a> | <a href="https://javascript.hotexamples.com/fr/">JavaScript</a> | <a href="https://typescript.hotexamples.com/fr/">TypeScript</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://doc.hotexamples.com/class/-/Menu_Item_Command">EN</a> | <a href="https://doc.hotexamples.com/ru/class/-/Menu_Item_Command">RU</a> | <a href="https://doc.hotexamples.com/de/class/-/Menu_Item_Command">DE</a> | <a href="https://doc.hotexamples.com/fr/class/-/Menu_Item_Command">FR</a> | <a href="https://doc.hotexamples.com/es/class/-/Menu_Item_Command">ES</a> | <a href="https://doc.hotexamples.com/pt/class/-/Menu_Item_Command">PT</a> | <a href="https://doc.hotexamples.com/it/class/-/Menu_Item_Command">IT</a> | <a href="https://doc.hotexamples.com/jp/class/-/Menu_Item_Command">JP</a> | <a href="https://doc.hotexamples.com/zh/class/-/Menu_Item_Command">ZH</a> | <a href="https://doc.hotexamples.com/ko/class/-/Menu_Item_Command">KO</a> </div> </div> <div class="row"> <div class="col-md-10 col-md-offset-1"> </div> <div class="col-md-1"> <!--LiveInternet counter--> <script type="text/javascript"><!-- document.write("<a href='//www.liveinternet.ru/click' " + "target=_blank><img src='//counter.yadro.ru/hit?t44.6;r" + escape(document.referrer) + ((typeof (screen) == "undefined") ? "" : ";s" + screen.width + "*" + screen.height + "*" + (screen.colorDepth ? screen.colorDepth : screen.pixelDepth)) + ";u" + escape(document.URL) + ";" + Math.random() + "' alt='' title='LiveInternet' " + "border='0' width='31' height='31'><\/a>"); //--></script><!--/LiveInternet--> </div> </div> </div> </footer> <script src="//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="/assets/30dd86a6f06b64184847037c52c63e07aa3c9a26.js"></script> <script>jQuery(function ($) { jQuery('#search-form').yiiActiveForm([{"id":"searchform-lang","name":"lang","container":".field-searchform-lang","input":"#searchform-lang","enableAjaxValidation":true},{"id":"searchform-search","name":"search","container":".field-searchform-search","input":"#searchform-search","enableAjaxValidation":true,"validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"Search ne peut être vide."});}}], []); });</script></body> </html>