PHP 在wordpress页面主题中插入img

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 在wordpress页面主题中插入img相关的知识,希望对你有一定的参考价值。

<?php if ( is_page(array(1,2,3)) ) {    
    // the page is "About", or the parent of the page is "About"
    $bannerimg = '1';

} elseif ( is_pagearray(4)) ) {	
    $bannerimg = '2';

} elseif ( is_page('home') ) {	
	$bannerimg = '3';

} else {
	$bannerimg = '4';
} ?>

<img src="<?php bloginfo('template_url'); ?>/images/image_<?php echo $bannerimg ?>.jpg" alt="<?php the_title(); ?>">

以上是关于PHP 在wordpress页面主题中插入img的主要内容,如果未能解决你的问题,请参考以下文章