2011-04-20 17:46:33 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Template Name: Showcase Template
|
|
|
|
* Description: A Page Template that showcases Sticky Posts, Asides, and Blog Posts
|
|
|
|
*
|
2011-04-28 20:19:02 -04:00
|
|
|
* The showcase template in Twenty Eleven consists of a featured posts section using sticky posts,
|
|
|
|
* another recent posts area (with the latest post shown in full and the rest as a list)
|
|
|
|
* and a left sidebar holding aside posts.
|
|
|
|
*
|
|
|
|
* We are creating two queries to fetch the proper posts and a custom widget for the sidebar.
|
|
|
|
*
|
2011-04-20 17:46:33 -04:00
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Twenty Eleven
|
2011-05-02 17:04:44 -04:00
|
|
|
* @since Twenty Eleven 1.0
|
2011-04-20 17:46:33 -04:00
|
|
|
*/
|
|
|
|
|
2011-04-28 20:19:02 -04:00
|
|
|
// Enqueue showcase script for the slider
|
|
|
|
wp_enqueue_script( 'twentyeleven-showcase', get_template_directory_uri() . '/js/showcase.js', array( 'jquery' ), '2011-04-28' );
|
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
get_header(); ?>
|
|
|
|
|
|
|
|
<div id="primary" class="showcase">
|
|
|
|
<div id="content" role="main">
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php the_post(); ?>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php
|
2011-04-28 20:19:02 -04:00
|
|
|
/**
|
|
|
|
* We are using a heading by rendering the_content
|
|
|
|
* If we have content for this page, let's display it.
|
|
|
|
*/
|
2011-04-20 17:46:33 -04:00
|
|
|
if ( '' != get_the_content() )
|
|
|
|
get_template_part( 'content', 'intro' );
|
|
|
|
?>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php
|
2011-04-28 20:19:02 -04:00
|
|
|
/**
|
|
|
|
* Begin the featured posts section.
|
|
|
|
*
|
|
|
|
* See if we have any sticky posts and use them to create our featured posts.
|
2011-05-03 16:16:34 -04:00
|
|
|
* We limit the featured posts at ten.
|
2011-04-28 20:19:02 -04:00
|
|
|
*/
|
2011-04-20 17:46:33 -04:00
|
|
|
$sticky = get_option( 'sticky_posts' );
|
|
|
|
$featured_args = array(
|
2011-05-03 16:16:34 -04:00
|
|
|
'posts_per_page' => 10,
|
2011-04-20 17:46:33 -04:00
|
|
|
'post__in' => $sticky,
|
|
|
|
);
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-28 20:19:02 -04:00
|
|
|
// The Featured Posts query.
|
2011-04-20 17:46:33 -04:00
|
|
|
$featured = new WP_Query();
|
|
|
|
$featured->query( $featured_args );
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-28 20:19:02 -04:00
|
|
|
/**
|
|
|
|
* We will need to count featured posts starting from zero
|
|
|
|
* to create the slider navigation.
|
|
|
|
*/
|
|
|
|
$counter_slider = 0;
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div class="featured-posts">
|
|
|
|
<h1 class="showcase-heading"><?php _e( 'Featured Post', 'twentyeleven' ); ?></h1>
|
|
|
|
|
|
|
|
<?php
|
2011-04-20 17:46:33 -04:00
|
|
|
// Let's roll.
|
2011-04-28 20:19:02 -04:00
|
|
|
while ( $featured->have_posts() ) : $featured->the_post();
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-28 20:19:02 -04:00
|
|
|
// Increase the counter.
|
|
|
|
$counter_slider++;
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-28 20:19:02 -04:00
|
|
|
/**
|
|
|
|
* We're going to add a class to our featured post for featured images
|
|
|
|
* by default it'll have no class though.
|
|
|
|
*/
|
2011-04-20 17:46:33 -04:00
|
|
|
$feature_class = '';
|
|
|
|
|
|
|
|
if ( has_post_thumbnail() ) {
|
2011-04-28 20:19:02 -04:00
|
|
|
// ... but if it has a featured image let's add some class
|
2011-04-20 17:46:33 -04:00
|
|
|
$feature_class = 'feature-image small';
|
|
|
|
|
|
|
|
// Hang on. Let's check this here image out.
|
|
|
|
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) );
|
|
|
|
|
|
|
|
// Is it bigger than or equal to our header?
|
|
|
|
if ( $image[1] >= HEADER_IMAGE_WIDTH ) {
|
2011-04-28 20:19:02 -04:00
|
|
|
// If bigger, let's add a BIGGER class. It's EXTRA classy now.
|
2011-04-20 17:46:33 -04:00
|
|
|
$feature_class = 'feature-image large';
|
|
|
|
}
|
|
|
|
}
|
2011-04-28 20:19:02 -04:00
|
|
|
?>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php if ( has_post_thumbnail() ) : ?>
|
2011-04-28 20:19:02 -04:00
|
|
|
<section class="featured-post <?php echo $feature_class; ?>" id="featured-post-<?php echo $counter_slider; ?>">
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php else : ?>
|
2011-04-28 20:19:02 -04:00
|
|
|
<section class="featured-post" id="featured-post-<?php echo $counter_slider; ?>">
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php endif; ?>
|
2011-04-28 20:19:02 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php
|
2011-04-28 20:19:02 -04:00
|
|
|
/**
|
|
|
|
* If the thumbnail is as big as the header image
|
|
|
|
* make it a large featured post, otherwise render it small
|
|
|
|
*/
|
2011-04-20 17:46:33 -04:00
|
|
|
if ( has_post_thumbnail() ) {
|
|
|
|
if ( $image[1] >= HEADER_IMAGE_WIDTH ) { ?>
|
|
|
|
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"> <?php the_post_thumbnail( 'large-feature' ); ?></a>
|
|
|
|
<?php } else { ?>
|
|
|
|
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail( 'small-feature' ); ?></a>
|
|
|
|
<?php }
|
2011-04-26 14:34:52 -04:00
|
|
|
}
|
|
|
|
?>
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php get_template_part( 'content', 'featured' ); ?>
|
2011-04-26 14:34:52 -04:00
|
|
|
</section>
|
2011-04-28 20:19:02 -04:00
|
|
|
<?php endwhile; ?>
|
|
|
|
|
|
|
|
<nav class="feature-slider">
|
|
|
|
<ul>
|
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* We need to query the same set of posts again
|
|
|
|
* to populate the navigation dots
|
|
|
|
*/
|
|
|
|
$featured->query( $featured_args );
|
|
|
|
|
|
|
|
// Reset the counter so that we end up with matching elements
|
|
|
|
$counter_slider = 0;
|
|
|
|
|
|
|
|
// Begin from zero
|
|
|
|
rewind_posts();
|
|
|
|
|
|
|
|
// Let's roll again.
|
|
|
|
while ( $featured->have_posts() ) : $featured->the_post();
|
|
|
|
$counter_slider++;
|
|
|
|
?>
|
|
|
|
<li><a href="#featured-post-<?php echo $counter_slider; ?>" title="<?php printf( esc_attr__( 'Featuring: %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" <?php
|
|
|
|
if ( 1 == $counter_slider ) :
|
|
|
|
echo 'class="active"';
|
|
|
|
endif;
|
|
|
|
?>></a></li>
|
|
|
|
<?php endwhile; ?>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</div>
|
2011-04-20 17:46:33 -04:00
|
|
|
|
|
|
|
<section class="recent-posts">
|
|
|
|
<h1 class="showcase-heading"><?php _e( 'Recent Posts', 'twentyeleven' ); ?></h1>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php
|
|
|
|
|
2011-04-28 20:19:02 -04:00
|
|
|
// Display our recent posts, showing full content for the very latest, ignoring Aside posts.
|
2011-04-20 17:46:33 -04:00
|
|
|
$recent_args = array(
|
|
|
|
'order' => 'DESC',
|
|
|
|
'post__not_in' => get_option( 'sticky_posts' ),
|
|
|
|
'tax_query' => array(
|
|
|
|
array(
|
|
|
|
'taxonomy' => 'post_format',
|
2011-04-26 14:46:31 -04:00
|
|
|
'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ),
|
2011-04-20 17:46:33 -04:00
|
|
|
'field' => 'slug',
|
|
|
|
'operator' => 'NOT IN',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2011-04-28 20:19:02 -04:00
|
|
|
// Our new query for the Recent Posts section.
|
2011-04-20 17:46:33 -04:00
|
|
|
$recent = new WP_Query();
|
|
|
|
$recent->query( $recent_args );
|
|
|
|
$counter = 0;
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
while ( $recent->have_posts() ) : $recent->the_post();
|
2011-04-28 20:19:02 -04:00
|
|
|
// Set $more to 0 in order to only get the first part of the post.
|
2011-04-20 17:46:33 -04:00
|
|
|
global $more;
|
2011-04-26 14:34:52 -04:00
|
|
|
$more = 0;
|
2011-04-20 17:46:33 -04:00
|
|
|
$counter++;
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
if ( 1 == $counter ) :
|
|
|
|
get_template_part( 'content', get_post_format() );
|
|
|
|
echo '<ol class="other-recent-posts">';
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
else : ?>
|
|
|
|
<li class="entry-title">
|
|
|
|
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
|
|
|
|
<span class="comments-link">
|
|
|
|
<?php comments_popup_link( __( '<span class="leave-reply">Leave a reply</span>', 'twentyeleven' ), __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?>
|
|
|
|
</span>
|
|
|
|
</li>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php endif;
|
|
|
|
endwhile;
|
|
|
|
?>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
</ol>
|
|
|
|
</section>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<div class="widget-area" role="complementary">
|
|
|
|
<?php if ( ! dynamic_sidebar( 'sidebar-2' ) ) : ?>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php
|
|
|
|
the_widget( 'Twenty_Eleven_Ephemera_Widget', '', 'before_title=<h1 class="widget-title">&after_title=</h1>' );
|
2011-04-26 14:34:52 -04:00
|
|
|
?>
|
2011-04-20 17:46:33 -04:00
|
|
|
|
|
|
|
<?php endif; // end sidebar widget area ?>
|
|
|
|
</div><!-- .widget-area -->
|
|
|
|
|
|
|
|
</div><!-- #content -->
|
|
|
|
</div><!-- #primary -->
|
|
|
|
|
|
|
|
<?php get_footer(); ?>
|