admin管理员组文章数量:1122832
I want to keep different image on the single post type page and a different image if the post type is showing in a loop. Is there any way?
Perhaps we can use the gallery image as featured on single view but if so, how?
I want to keep different image on the single post type page and a different image if the post type is showing in a loop. Is there any way?
Perhaps we can use the gallery image as featured on single view but if so, how?
Share Improve this question edited Jun 6, 2016 at 12:54 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Jun 6, 2016 at 12:08 Irfan SaleemIrfan Saleem 111 bronze badge 1- if you just want a different image size of the same image, you can do that a bit simpler, otherwise use @cjbj's solution. – majick Commented Jun 6, 2016 at 14:42
1 Answer
Reset to default 0The easiest way to achieve this is to use the Multiple Post Thumbnails plugin. Once you have done this, add the following snippet to your functions file:
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(array(
'label' => __('Secondary Featured Image', 'yourtextdomain')
'id' => 'secondary-image',
'post_type' => 'post'
));
}
This will make a box 'Secondary Featured Image' available on your edit post page. Now you will have to place it in your theme, wherever you want the secondary featured image to appear in stead of the primary:
if (class_exists('MultiPostThumbnails'))
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image');
else
the_post_thumbnail(); //fallback in case somebody doesn't have the plugin installed
本文标签: post thumbnailsDifferent Featured Images depending on context loop or single view
版权声明:本文标题:post thumbnails - Different Featured Images depending on context: loop or single view 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736292754a1929001.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论