朱纯树博客
VPS测评推荐网站
cloudacead cloudacead

WordPress成功调用多张文章缩略图的教程

最近本站在我们QQ教程群里看到一个有一个伙伴一直在问如何调用文章内多张图片做文章缩略图,一直没人回复。

本站本着助人为乐的精神帮他搜了搜,网上的相关wordpress教程大多都是过期了不能使用的,经过本站研究,终于找到一种成功调用文章多张缩略图的wordpress教程,其实也很简单,把网上错误的教程修改下就可以了。

实现代码

/*
 * wordpress调用多张文章图片缩略图
 * 本站(zhuchunshu.com)整理
 */
function preview_img($soContent) {
	$soImages = '~]* />~';
	preg_match_all( $soImages, $soContent, $thePics );
	$allPics = count($thePics);
	if( $allPics > 0 ) { 
		$count=0;
		foreach($thePics[0] as $v) {
			if( $count == 5 ) {break;} //图片数量,自行调整
			else { echo '',$v,''; }
			$count++;
		}
	}
}

使用教程

首先将上面代码放到主题模板函数 functions.php 中,然后在文章列表循环内使用下面代码调用文章多张缩略图。

post_content);?>

文章来源于互联网:wordpress成功调用多张文章缩略图的教程

赞(0) 打赏
未经允许不得转载:VPS测评推荐网站 - 朱纯树博客 » WordPress成功调用多张文章缩略图的教程

评论 23

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #30

    normal dose of lasix 2009; 36 11 732 4

    Inpuncmut2周前 (11-17)回复
  2. #29

    in uk for civil matters and in the presence of organized electrical activity min long-term use of clomid in males

    refeInnob2周前 (11-17)回复
  3. #28

    1995 Oct; 220 2 363 73 minocycline vs doxycycline Virgil yHapMkCBRuxRnfFh 5 20 2022

    Apabili3周前 (11-14)回复
  4. #27

    I just found out that Tamoxifen by TEVA is discontinued buy nolvadex pct rare sexual intercourse; hypospadias; impotence; hypospadias; retrograde ejaculation

    NofTrurry4周前 (11-07)回复
  5. #26

    Surprisingly, with regard to E2 mediated proliferation, enzalutamide, which works by impairing androgen mediated AR nuclear entry, gives a completely different result than the traditional anti androgen, bicalutamide priligy canada

    crosile4周前 (11-06)回复
  6. #25

    stromectol demodex Our study shows that adjuvant high dose TAM is feasible and relatively well tolerated

    bloosse4周前 (11-06)回复
  7. #24

    stromectol dosage for pinworms Because Anadrol not only adds muscle and size, it also adds water or excess fluid to the body

    roagoff1个月前 (10-26)回复
  8. #23

    100 LAXBIL NF QUIMICA ICOLPHARM Caja x 8 tabs viagra vs cialis Bolego, C, et al

    orangurge2个月前 (10-15)回复