2011-04-20 23:46:33 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Template Name: Showcase Template
|
|
|
|
* Description: A Page Template that showcases Sticky Posts, Asides, and Blog Posts
|
|
|
|
*
|
2011-04-29 02:19:02 +02: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 23:46:33 +02:00
|
|
|
* @package WordPress
|
2011-05-18 21:06:09 +02:00
|
|
|
* @subpackage Twenty_Eleven
|
2011-05-02 23:04:44 +02:00
|
|
|
* @since Twenty Eleven 1.0
|
2011-04-20 23:46:33 +02:00
|
|
|
*/
|
|
|
|
|
2011-04-29 02:19:02 +02: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 23:46:33 +02:00
|
|
|
get_header(); ?>
|
|
|
|
|
|
|
|
<div id="primary" class="showcase">
|
|
|
|
<div id="content" role="main">
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php the_post(); ?>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php
|
2011-04-29 02:19:02 +02:00
|
|
|
/**
|
|
|
|
* We are using a heading by rendering the_content
|
|
|
|
* If we have content for this page, let's display it.
|
|
|
|
*/
|
2011-04-20 23:46:33 +02:00
|
|
|
if ( '' != get_the_content() )
|
|
|
|
get_template_part( 'content', 'intro' );
|
|
|
|
?>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php
|
2011-04-29 02:19:02 +02:00
|
|
|
/**
|
|
|
|
* Begin the featured posts section.
|
|
|
|
*
|
|
|
|
* See if we have any sticky posts and use them to create our featured posts.
|
2011-05-03 22:16:34 +02:00
|
|
|
* We limit the featured posts at ten.
|
2011-04-29 02:19:02 +02:00
|
|
|
*/
|
2011-04-20 23:46:33 +02:00
|
|
|
$sticky = get_option( 'sticky_posts' );
|
2011-06-09 18:39:40 +02:00
|
|
|
|
|
|
|
// Proceed only if sticky posts exist.
|
|
|
|
if ( ! empty( $sticky ) ) :
|
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
$featured_args = array(
|
|
|
|
'post__in' => $sticky,
|
2011-05-10 01:15:38 +02:00
|
|
|
'post_status' => 'publish',
|
2011-05-10 00:54:55 +02:00
|
|
|
'posts_per_page' => 10,
|
2011-06-10 22:14:59 +02:00
|
|
|
'no_found_rows' => true,
|
2011-04-20 23:46:33 +02:00
|
|
|
);
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-29 02:19:02 +02:00
|
|
|
// The Featured Posts query.
|
2011-05-10 01:15:38 +02:00
|
|
|
$featured = new WP_Query( $featured_args );
|
2011-06-09 18:53:01 +02:00
|
|
|
|
|
|
|
// Proceed only if published posts exist
|
|
|
|
if ( $featured->have_posts() ) :
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-29 02:19:02 +02: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 23:46:33 +02:00
|
|
|
// Let's roll.
|
2011-04-29 02:19:02 +02:00
|
|
|
while ( $featured->have_posts() ) : $featured->the_post();
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-29 02:19:02 +02:00
|
|
|
// Increase the counter.
|
|
|
|
$counter_slider++;
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-29 02:19:02 +02: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 23:46:33 +02:00
|
|
|
$feature_class = '';
|
|
|
|
|
|
|
|
if ( has_post_thumbnail() ) {
|
2011-04-29 02:19:02 +02:00
|
|
|
// ... but if it has a featured image let's add some class
|
2011-04-20 23:46:33 +02: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-29 02:19:02 +02:00
|
|
|
// If bigger, let's add a BIGGER class. It's EXTRA classy now.
|
2011-04-20 23:46:33 +02:00
|
|
|
$feature_class = 'feature-image large';
|
|
|
|
}
|
2011-06-07 23:28:56 +02:00
|
|
|
} else {
|
|
|
|
$feature_class = 'feature-text';
|
2011-04-20 23:46:33 +02:00
|
|
|
}
|
2011-04-29 02:19:02 +02:00
|
|
|
?>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php if ( has_post_thumbnail() ) : ?>
|
2011-04-29 02:19:02 +02:00
|
|
|
<section class="featured-post <?php echo $feature_class; ?>" id="featured-post-<?php echo $counter_slider; ?>">
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php else : ?>
|
2011-04-29 02:19:02 +02:00
|
|
|
<section class="featured-post" id="featured-post-<?php echo $counter_slider; ?>">
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php endif; ?>
|
2011-04-29 02:19:02 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php
|
2011-04-29 02:19:02 +02:00
|
|
|
/**
|
|
|
|
* If the thumbnail is as big as the header image
|
|
|
|
* make it a large featured post, otherwise render it small
|
|
|
|
*/
|
2011-04-20 23:46:33 +02: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 20:34:52 +02:00
|
|
|
}
|
|
|
|
?>
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php get_template_part( 'content', 'featured' ); ?>
|
2011-04-26 20:34:52 +02:00
|
|
|
</section>
|
2011-04-29 02:19:02 +02:00
|
|
|
<?php endwhile; ?>
|
|
|
|
|
2011-05-10 00:54:55 +02:00
|
|
|
<?php
|
|
|
|
// Show slider only if we have more than one featured post.
|
2011-05-10 01:15:38 +02:00
|
|
|
if ( $featured->post_count > 1 ) :
|
2011-05-10 00:54:55 +02:00
|
|
|
?>
|
2011-04-29 02:19:02 +02:00
|
|
|
<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>
|
2011-05-10 00:54:55 +02:00
|
|
|
<?php endif; // End check for more than one sticky post. ?>
|
|
|
|
</div><!-- .featured-posts -->
|
2011-06-09 18:53:01 +02:00
|
|
|
<?php endif; // End check for published posts. ?>
|
2011-05-10 00:54:55 +02:00
|
|
|
<?php endif; // End check for sticky posts. ?>
|
2011-04-20 23:46:33 +02:00
|
|
|
|
|
|
|
<section class="recent-posts">
|
|
|
|
<h1 class="showcase-heading"><?php _e( 'Recent Posts', 'twentyeleven' ); ?></h1>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php
|
|
|
|
|
2011-04-29 02:19:02 +02:00
|
|
|
// Display our recent posts, showing full content for the very latest, ignoring Aside posts.
|
2011-04-20 23:46:33 +02:00
|
|
|
$recent_args = array(
|
|
|
|
'order' => 'DESC',
|
|
|
|
'post__not_in' => get_option( 'sticky_posts' ),
|
|
|
|
'tax_query' => array(
|
|
|
|
array(
|
|
|
|
'taxonomy' => 'post_format',
|
2011-04-26 20:46:31 +02:00
|
|
|
'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ),
|
2011-04-20 23:46:33 +02:00
|
|
|
'field' => 'slug',
|
|
|
|
'operator' => 'NOT IN',
|
|
|
|
),
|
|
|
|
),
|
2011-06-10 22:14:59 +02:00
|
|
|
'no_found_rows' => true,
|
2011-04-20 23:46:33 +02:00
|
|
|
);
|
2011-04-29 02:19:02 +02:00
|
|
|
// Our new query for the Recent Posts section.
|
2011-04-20 23:46:33 +02:00
|
|
|
$recent = new WP_Query();
|
|
|
|
$recent->query( $recent_args );
|
|
|
|
$counter = 0;
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
while ( $recent->have_posts() ) : $recent->the_post();
|
2011-04-29 02:19:02 +02:00
|
|
|
// Set $more to 0 in order to only get the first part of the post.
|
2011-04-20 23:46:33 +02:00
|
|
|
global $more;
|
2011-04-26 20:34:52 +02:00
|
|
|
$more = 0;
|
2011-04-20 23:46:33 +02:00
|
|
|
$counter++;
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
if ( 1 == $counter ) :
|
|
|
|
get_template_part( 'content', get_post_format() );
|
|
|
|
echo '<ol class="other-recent-posts">';
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02: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 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php endif;
|
|
|
|
endwhile;
|
|
|
|
?>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
</ol>
|
2011-05-10 00:54:55 +02:00
|
|
|
</section><!-- .recent-posts -->
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<div class="widget-area" role="complementary">
|
|
|
|
<?php if ( ! dynamic_sidebar( 'sidebar-2' ) ) : ?>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php
|
|
|
|
the_widget( 'Twenty_Eleven_Ephemera_Widget', '', 'before_title=<h1 class="widget-title">&after_title=</h1>' );
|
2011-04-26 20:34:52 +02:00
|
|
|
?>
|
2011-04-20 23:46:33 +02:00
|
|
|
|
|
|
|
<?php endif; // end sidebar widget area ?>
|
|
|
|
</div><!-- .widget-area -->
|
|
|
|
|
|
|
|
</div><!-- #content -->
|
|
|
|
</div><!-- #primary -->
|
|
|
|
|
|
|
|
<?php get_footer(); ?>
|