<?php
//Put this in functions.php
function get_primary_image($id, $size){
$featured = wp_get_attachment_image_src( get_post_thumbnail_id($id), $size, false);
if($featured){
$childURL = $featured['0'];
}else{
$children = get_children(array('post_parent' => $id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => 1));
reset($children);
$childID = key($children);
//$childURL = wp_get_attachment_url($childID);
$childArray = wp_get_attachment_image_src($childID, $size, false);
$childURL = $childArray['0'];
if(empty($childURL)){
$childURL = get_bloginfo('template_url')."/images/default.png";
}
}
return($childURL);
}
//Run this in the loop (or any place you'd like - as long as you have an ID to feed it..)
//First argument is the ID..
//Second argument is the size.. It'll handle 'large', 'medium', 'thumbnail' or even
'array(100, 100)'..
get_primary_image(get_the_ID(), 'large');
?>
以上就是安达网络工作室关于《Wordpress 显示主题图片的实现代码》的一些看法。更多内容请查看本栏目更多内容!
上面是详细处理流程:1 首先关上phpadmin,从右边的表中抉择xx_opition2 在xx_opition中进行查问,在查问框...
最近遇到一个从站内查用WordPress站内文章成绩,详细是这样的:需求在A站的首页或许侧边栏援用B站点的最新文...
很多冤家刚建设博客的时分都是采纳国际优秀的博客零碎:Z-BLOG,用一段工夫当时很多人都想转移到wordpress,...
1.增加性能 在function.php中拔出代码 add_theme_support('post-thumbnails'); 拔出之后会在后盾编辑文章的...
要害字形容:工作 预备 装置   数据库 用户 创立 权限 应用 软件 解说 WordPress 的装置前的一些预备工...
共性化登陆界面的办法有两种,第一种是交换登陆背景,这个算是小型共性化吧: 在/wp-admin/images找到login...