开发者

Why is my secondary featured image not showing in using Wordpress?

I am using wordpress and am using featured images(they used to be called post thumbnails). I wanted to use multiple featured images, so I chose to use the Multiple Post Thumbnails开发者_开发知识库 Plugin.

I can get the Secondary Image Upload box to show up in the admin area, but I can't manage to get the image to display on the page.

This is the code I am using to try and make it display (From: http://wordpress.org/extend/plugins/multiple-post-thumbnails/installation/):

<?php if (class_exists('MultiPostThumbnails')
    && MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image')) :
        MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image'); endif; ?>

I tried adding a random echo inside the if statement to see if it gets hit, but it doesn't echo out, so i'm guessing somehow the condition is not being met?

What am I missing?


First of all, I guess it is necessary to enable thumbnails, too:

// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );

Then you have to add something like

if (class_exists('MultiPostThumbnails')) {
    $types = array('post', 'page', 'my_post_type');
    foreach($types as $type) {
        $thumb = new MultiPostThumbnails(array(
            'label' => 'Secondary Image',
            'id' => 'secondary-image',
            'post_type' => $type
            )
        );
    }
}

in your themes functions.php file within the theme_setup() {...} function.

HTH, mtness.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜