Wordpress多个帖子缩略图插件 - 代码问题

时间:2011-12-01 12:50:01

标签: wordpress-plugin thumbnails

我在运行这个插件时遇到了问题,但即使在读完过去的条目之后也没有成功。如果您能看到代码是否正确,我将不胜感激。

functions.php中的代码:

// Add secondary thumbnail (featured image) in posts */
if (class_exists('MultiPostThumbnails')) { new MultiPostThumbnails(array
( 'label'  =>
'Secondary Image', 'id' => 'secondary-image', 'post_type' => 'post'
));
add_image_size('post-secondary-image-thumbnail', 176, 58, true);

new MultiPostThumbnails(array(
'label' => 'Tertiary Image',
'id' => 'tertiary-image',
));
add_image_size('post-tertiary-image-thumbnail', 176, 58, true);

new MultiPostThumbnails(array(
'label' => 'Quaternary Image',
'id' => 'quaternary-image',
));
add_image_size('post-quaternary-image-thumbnail', 176, 58, true);
}

模板中的代码(我已经发布了整个模板代码,因为我认为你需要完整地看到它):

<?php

/*
Template Name: Home
*/

?>
<?php get_header(); ?>

<div id='main-content'>

    <h2>What We Do</h2>

    <ul id="we-do">

<?php query_posts("posts_per_page=1&post_type=page&page_id=168"); 
         the_post (); ?>
    <!--If you want to refer to the child of parent page, use "post_parent=" -->
    <li>
        <h3><?php the_title(); ?></h3>
         <?php the_excerpt(); ?>
         <?php if (class_exists('MultiPostThumbnails')
&& MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image')) :
MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image'); endif; ?>
        <a href="<?php the_permalink(); ?>" class="button">View More</a>
    </li>

<?php query_posts("posts_per_page=1&post_type=page&page_id=236"); the_post(); ?>

    <li>
        <h3><?php the_title(); ?></h3>
        <p><?php the_excerpt(); ?></p>
        <?php if (class_exists('MultiPostThumbnails')
&& MultiPostThumbnails::has_post_thumbnail('post', 'tertiary-image')) :
MultiPostThumbnails::the_post_thumbnail('post', 'tertiary-image'); endif; ?>
        <a href="<?php the_permalink(); ?>" class="button">View More</a>
   </li>

<?php query_posts("posts_per_page=1&post_type=page&page_id=240"); the_post(); ?>

    <li>    

        <h3><?php the_title(); ?></h3>
        <?php the_excerpt(); ?>
         <?php if (class_exists('MultiPostThumbnails')
&& MultiPostThumbnails::has_post_thumbnail('post', 'quaternary-image')) :
MultiPostThumbnails::the_post_thumbnail('post', 'quaternary-image'); endif; ?>
        <a href="<?php the_permalink(); ?>" class="button">View More</a>
  </li>
     </ul>

</div><!--END main-content-->

<?php get_sidebar(); ?>

<?php get_footer(); ?>

我还想在图像中应用一个类,但不确定放置数组的位置。

可能需要注意的是,我还运行了特色图像功能,该功能也在功能模板中注册。

0 个答案:

没有答案