调用文章所有图片
首先在function.php里面写一个函数,代码如下 1 2 3 4 5 6 7 8 9 10 11 12 …
首先在function.php里面写一个函数,代码如下
| 
 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
 | 
 
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’),
 
));
 
 | 
然后再需要调用的地方写入
| 
 1 
 | 
 
<?php all_img($post->post_content);?>
 
 | 
类别:WordPress开发、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论功能已经关闭!