WIKI使用導(dǎo)航
站長(zhǎng)百科導(dǎo)航
站長(zhǎng)專題
- 網(wǎng)站推廣
- 網(wǎng)站程序
- 網(wǎng)站賺錢
- 虛擬主機(jī)
- cPanel
- 網(wǎng)址導(dǎo)航專題
- 云計(jì)算
- 微博營銷
- 虛擬主機(jī)管理系統(tǒng)
- 開放平臺(tái)
- WIKI程序與應(yīng)用
- 美國十大主機(jī)
編輯“WordPress:Function Reference/delete post meta”
該編輯可以被撤銷。 請(qǐng)檢查下面的對(duì)比以核實(shí)您想要撤銷的內(nèi)容,然后發(fā)布下面的更改以完成撤銷。
最后版本 | 您的文本 | ||
第1行: | 第1行: | ||
== | ==Description== | ||
? | This function deletes all custom fields with the specified key from the specified post. See also [[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/get post meta|get_post_meta()]] and [[WordPress:Function Reference/add post meta|add_post_meta()]]. | ||
==Usage== | |||
? | |||
== | |||
? | |||
%%% <?php delete_post_meta($post_id, $key, $value); ?> %%% | %%% <?php delete_post_meta($post_id, $key, $value); ?> %%% | ||
==Examples== | |||
===Default Usage=== | |||
<?php delete_post_meta(76, 'my_key', 'Steve'); ?> | |||
===Other Examples=== | |||
Let's assume we had a plugin that added some meta values to posts, but now when we are uninstalling the plugin, we want to delete all the post meta keys that the plugin added. Assuming the plugin added the keys <tt>related_posts</tt> and <tt>post_inspiration</tt>. | |||
To delete all the keys, this would be added to the "uninstall" function: | |||
? | |||
? | |||
? | |||
? | |||
<pre><?php | <pre><?php | ||
?? $allposts = get_posts('numberposts=0&post_type=post&post_status='); | ?? $allposts = get_posts('numberposts=0&post_type=post&post_status='); | ||
第26行: | 第19行: | ||
?></pre> | ?></pre> | ||
Or, if you wanted to delete all the keys except where <tt>post_inspiration</tt> was "Sherlock Holmes": | |||
<pre><?php | <pre><?php | ||
第41行: | 第34行: | ||
?></pre> | ?></pre> | ||
? | Or maybe post number 185 was just deleted, and you want to remove all <tt>related_posts</tt> keys that reference it: | ||
<pre><?php | <pre><?php | ||
第51行: | 第43行: | ||
?? } | ?? } | ||
?></pre> | ?></pre> | ||
For a more detailed example, go to the [[WordPress:Function Reference/post meta Function Examples|post_meta Functions Examples]] page. | |||
'''''Note:''' Unlike [[WordPress:Function Reference/update post meta|update_post_meta()]], This function will delete '''all''' fields that match the criteria.'' | |||
? | |||
''''' | |||
? | |||
? | |||
{{Parameter|$value|string| | ==Parameters== | ||
{{Parameter|$post_id|integer|The ID of the post from which you will delete a field.}} | |||
{{Parameter|$key|string|The key of the field you will delete.}} | |||
{{Parameter|$value|string|The value of the field you will delete. This is used to differentiate between several fields with the same key. If left blank, all fields with the given key will be deleted.|optional}} | |||
== | ==Related== | ||
[[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/get post meta|get_post_meta()]], [[WordPress:Function Reference/add post meta|add_post_meta()]], [[WordPress:Function Reference/get post custom|get_post_custom()]], [[WordPress:Function Reference/get post custom values|get_post_custom_values()]], [[WordPress:Function Reference/get post custom keys|get_post_custom_keys()]] | [[WordPress:Function Reference/update post meta|update_post_meta()]], [[WordPress:Function Reference/get post meta|get_post_meta()]], [[WordPress:Function Reference/add post meta|add_post_meta()]], [[WordPress:Function Reference/get post custom|get_post_custom()]], [[WordPress:Function Reference/get post custom values|get_post_custom_values()]], [[WordPress:Function Reference/get post custom keys|get_post_custom_keys()]] |