1

如何检查有多少自定义字段有帖子,我不想检索任何值,但我需要找出有多少自定义字段有帖子。

4

1 回答 1

1
<?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);
?>

还有get_post_customget_post_custom_values

于 2012-05-27T17:21:07.567 回答