将下面的函数加入主题模板 functions.php 文件中 WordPress 获取文章中的图片个数函数 /* * 获取文章中的图片个数 (使用在文章列表主循环中、或文章页中) */ if( !function_exists('get_post_images_number') ){ function get_post_images_number(){ global $post; $content = $post->post_content; preg_match_all('/<img.*?(?: |\\t|…