如何检查有多少自定义字段有WordPress的帖子?
答
<?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);
?>
它不为我工作 - 回声$ num_cfields总是返回“1”,不管多的自定义字段如何张贴了,我试过get_post_custom et_post_custom_values,相同的结果。 – Rorkkkk
它对我来说很完美 ID)); ?> – Havelock
新代码确实有效,谢谢。 – Rorkkkk