我使用wordpress Multiple Post Thumbnails 插件添加自定义帖子元框图像字段 .
if (class_exists('MultiPostThumbnails')) { new MultiPostThumbnails( array( 'label' => 'Homepage Full-Width', 'id' => 'homepage-full-width', 'post_type' => 'post' ) ); }
我想在我的网站主页大 Banner 默认特色图像(http://nimb.ws/YelErQ)中显示这个全新的特色图像 .
现在主题上面的主题特色图像显示使用主题front-page.php文件中的以下代码 .
<?php $lead_article = ot_get_option('lead_article'); if (has_post_thumbnail($lead_article)) : $lead_article_img_horizontal = wp_get_attachment_image_src(get_post_thumbnail_id($lead_article), "tol-horizontal"); $lead_article_img_vertical = wp_get_attachment_image_src(get_post_thumbnail_id($lead_article), "tol-vertical"); $lead_article_img_horizontal_src = esc_url( $lead_article_img_horizontal[0]); $lead_article_img_vertical_src = esc_url( $lead_article_img_vertical[0]); ?>
<div id="lead-article" class="post featured-style10 post-header">
<div data-interchange="[<?php echo $lead_article_img_horizontal_src ?>, landscape], [<?php echo $lead_article_img_vertical_src ?>, portrait]" class="parallax_bg skrollable skrollable-between" data-bottom-top="transform: translate3d(0px, -20%, 0px);" data-top-bottom="transform: translate3d(0px, 20%, 0px);" style="transform: translate3d(0px, 0.382158%, 0px);background-image: url(<?php echo $lead_article_img_horizontal_src ?>)"></div>
</div>
<?php endif; ?>
我有跟随插件指令https://github.com/voceconnect/multi-post-thumbnails/wiki但是在我的front-page.php文件中无效 .
所以任何人都知道解决方案,请帮助我 .
谢谢 .
1 回答
根据documentation,您需要做的就是将此代码添加到模板中以显示您的自定义缩略图:
请注意,要使此代码按原样运行,您需要将其放在The Loop内 .
Update:
假设
ot_get_option('lead_article')
返回一个ID,试试这个: