Created
November 1, 2010 13:15
-
-
Save austinginder/658140 to your computer and use it in GitHub Desktop.
Wordpress adding multiple featured images per post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add to | |
functions.php | |
// This theme uses post thumbnails | |
add_theme_support( 'post-thumbnails' ); | |
set_post_thumbnail_size( 300, 300, true ); | |
add_image_size( 'thumbnail-small', 75, 9999 ); | |
add_image_size( 'thumbnail-medium', 500, 9999 ); | |
$thumb2 = new MultiPostThumbnails(array( | |
'label' => 'Secondary Image', | |
'id' => 'secondary-image', | |
'post_type' => 'homes' | |
) | |
); | |
$thumb3 = new MultiPostThumbnails(array( | |
'label' => 'Third Image', | |
'id' => 'third-image', | |
'post_type' => 'homes' | |
) | |
); | |
$thumb4 = new MultiPostThumbnails(array( | |
'label' => 'Fourth Image', | |
'id' => 'fourth-image', | |
'post_type' => 'homes' | |
) | |
); | |
$thumb5 = new MultiPostThumbnails(array( | |
'label' => 'Fifth Image', | |
'id' => 'fifth-image', | |
'post_type' => 'homes' | |
) | |
); | |
# Add some javascript library such as gallery view | |
header.php | |
<script src="<?php bloginfo('template_url'); ?>/js/jquery.galleryview-2.1.1.js" type="text/javascript"></script> | |
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('template_url'); ?>/js/galleryview.css" /> | |
# in view | |
templatename.php | |
<script> | |
jQuery().ready(function($) { | |
$('#gallery').galleryView({ | |
transition_interval: 10000000, | |
panel_width: 300 | |
}); | |
if ($('#gallery li').length == 1) { | |
$('.strip_wrapper').css('display','none'); | |
$('.strip_wrapper').html(); | |
} | |
}); | |
</script> | |
<ul id="gallery"> | |
<li><?php the_post_thumbnail(); ?></li> | |
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('homes', 'secondary-image')) { ?> | |
<li><?php MultiPostThumbnails::the_post_thumbnail('homes', 'secondary-image'); ?></li> | |
<? } ?> | |
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('homes', 'third-image')) { ?> | |
<li><?php MultiPostThumbnails::the_post_thumbnail('homes', 'third-image'); ?></li> | |
<? } ?> | |
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('homes', 'fourth-image')) { ?> | |
<li><?php MultiPostThumbnails::the_post_thumbnail('homes', 'fourth-image'); ?></li> | |
<? } ?> | |
<?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('homes', 'fifth-image')) { ?> | |
<li><?php MultiPostThumbnails::the_post_thumbnail('homes', 'fifth-image'); ?></li> | |
<? } ?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which plugin should I use for this?