[英]Wordpress display multiple thumbnails in recent posts plugin
I would really appreciate any help on that issue. 我真的很感谢在这个问题上的任何帮助。 I'd like to display a second thumbail in recent posts section at the bottom of each single post template. 我想在每个帖子模板底部的“最近帖子”部分中显示第二个缩略图。
I'm using multipost thumbnails plug-in for wordpress. 我正在为Wordpress使用多帖子缩略图插件。 https://github.com/voceconnect/multi-post-thumbnails https://github.com/voceconnect/multi-post-thumbnails
and I'm using this code in my bottom widget area, which is working fine, but instead of a secondary image of each recent post, it shows a secondary image of a current post from above. 并且我在底部窗口小部件区域中使用了此代码,该代码工作正常,但不是从上方显示每个当前帖子的辅助图像,而是从每个近期帖子的辅助图像显示。
<?php $recent_posts = wp_get_recent_posts(55);
foreach( $recent_posts as $recent ){
if($recent['post_status']=="publish"){
if ( has_post_thumbnail($recent["ID"])) {
echo '<div id="main-grid">'
. '<a href="' . get_permalink($recent["ID"])
. '" title="Look '.esc_attr($recent["post_title"]).'" >'
. get_the_post_thumbnail($recent["ID"], 'large-thumb')
. MultiPostThumbnails::get_the_post_thumbnail('post','secondary-image')
. '<header class="entry-header"><h1>'
. $recent ["post_title"]
. '</h1></header>'
. '</a></div> ';
}
}
}
?>
You did not hand over the $recent["ID"]
to the MultiPostThumbnails function 您没有将$recent["ID"]
移交给MultiPostThumbnails函数
<?php
$recent_posts = wp_get_recent_posts(55);
foreach( $recent_posts as $recent ){
if($recent['post_status']=="publish"){
if ( has_post_thumbnail($recent["ID"])) {
echo '<div id="main-grid">'
. '<a href="' . get_permalink($recent["ID"])
. '" title="Look '.esc_attr($recent["post_title"]).'" >'
. get_the_post_thumbnail($recent["ID"], 'large-thumb')
.MultiPostThumbnails::get_the_post_thumbnail(
'post',
'secondary-image',
$recent["ID"],
'large-thumb'
)
. '<header class="entry-header"><h1>'
. $recent ["post_title"]
. '</h1></header>'
. '</a></div> ';
}
}
}
?>
Here you can find the function signature of get_the_post_thumbnail()
. 在这里,您可以找到get_the_post_thumbnail()
的函数签名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.