wordpress   发布时间:2022-05-06  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Wordpress 显示主题图片的实现代码大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="msgborder" id="PHPcode15"> <?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,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 显示主题图片的实现代码全部内容,希望文章能够帮你解决Wordpress 显示主题图片的实现代码所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: