如何检查有多少个自定义字段有帖子,我不想检索任何值,但我需要找出有多少个自定义字段有帖子。
<?php
// get only the keys as you only need the number
$cfields = get_post_custom_keys($post_id);
// num_cfields will store the number of custom fields
$num_cfields = count(cfields);
?>
There's also get_post_custom as well as get_post_custom_values
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.