我在 WordPress 中安装了一个自定义图片库,我想在其中一个页脚框中显示它们的数量?我已经尝试了很多,但这是唯一实际显示结果但错误的代码!
<?php
$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
if (0 < $numposts) $numposts = number_format($numposts);
echo 'We have published '.$numposts.' since our launch.';
?>