首先在function.php里面写一个函数:
function all_img($soContent){ $soImages = '~<img [^\>]*\ />~'; preg_match_all( $soImages, $soContent, $thePics ); $allPics = count($thePics); if( $allPics > 0 ){ foreach($thePics[0] as $v){ echo $v; } } else { echo "<img src='"; echo bloginfo('template_url'); echo "/images/thumb.gif'>"; } } register_nav_menus( array( 'primary' => __( 'Primary Navigation'), ));
需要调用的地方写:
<?php all_img($post->post_content);?>
赞