增加了特色图像的功能,但只有主题支持时才会显示出这个功能

如何为WordPress主题增加特色图像调用

WordPress新版本中增加了特色图像的功能,但只有主题支持时才会显示出这个功能 ,如何在主题中启用这个功能呢? 

1、 在主题functions.php中加入 

if ( function_exists( 'add_theme_support' ) ) { 

  add_theme_support( 'post-thumbnails' );
}
开启特色图像功能

 

2、之后在模版主循环后面适合位置加入调用代码

 

<?php
if(has_post_thumbnail()) {
    the_post_thumbnail();
} else {
    echo '<img src="'.get_bloginfo("template_url").'/images/img-default.png" />';
}
?>

纠结了好久的问题 你妹的
posted @ 2012-09-14 11:13  hust_zk  阅读(246)  评论(0编辑  收藏  举报