2011-04-20 17:46:33 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Template Name: Showcase Template
|
2013-09-25 12:50:11 -04:00
|
|
|
*
|
|
|
|
* Description: A Page Template that showcases Sticky Posts, Asides, and Blog Posts.
|
2011-04-20 17:46:33 -04:00
|
|
|
*
|
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
|
2011-05-18 15:06:09 -04:00
|
|
|
* @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
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
<?php
|
|
|
|
while ( have_posts() ) :
|
|
|
|
the_post();
|
|
|
|
?>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2013-10-09 16:39:09 -04:00
|
|
|
/*
|
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.
|
|
|
|
*/
|
2018-08-16 21:51:36 -04:00
|
|
|
if ( '' != get_the_content() ) {
|
|
|
|
get_template_part( 'content', 'intro' );
|
|
|
|
}
|
|
|
|
?>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-11-21 11:20:49 -05:00
|
|
|
<?php endwhile; ?>
|
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
<?php
|
2013-10-09 16:39:09 -04:00
|
|
|
/*
|
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' );
|
2011-06-09 12:39:40 -04:00
|
|
|
|
|
|
|
// Proceed only if sticky posts exist.
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! empty( $sticky ) ) :
|
2011-06-09 12:39:40 -04:00
|
|
|
|
2011-04-20 17:46:33 -04:00
|
|
|
$featured_args = array(
|
2017-11-30 18:11:00 -05:00
|
|
|
'post__in' => $sticky,
|
|
|
|
'post_status' => 'publish',
|
2011-05-09 18:54:55 -04:00
|
|
|
'posts_per_page' => 10,
|
2017-11-30 18:11:00 -05:00
|
|
|
'no_found_rows' => true,
|
2011-04-20 17:46:33 -04:00
|
|
|
);
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-04-28 20:19:02 -04:00
|
|
|
// The Featured Posts query.
|
2011-05-09 19:15:38 -04:00
|
|
|
$featured = new WP_Query( $featured_args );
|
2011-06-11 11:44:06 -04:00
|
|
|
|
2011-06-09 12:53:01 -04:00
|
|
|
// Proceed only if published posts exist
|
|
|
|
if ( $featured->have_posts() ) :
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
/*
|
|
|
|
* We will need to count featured posts starting from zero
|
|
|
|
* to create the slider navigation.
|
|
|
|
*/
|
|
|
|
$counter_slider = 0;
|
2011-04-28 20:19:02 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
// Compatibility with versions of WordPress prior to 3.4.
|
|
|
|
if ( function_exists( 'get_custom_header' ) ) {
|
|
|
|
$header_image_width = get_theme_support( 'custom-header', 'width' );
|
|
|
|
} else {
|
|
|
|
$header_image_width = HEADER_IMAGE_WIDTH;
|
|
|
|
}
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2011-04-28 20:19:02 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
<div class="featured-posts">
|
2011-04-28 20:19:02 -04:00
|
|
|
<h1 class="showcase-heading"><?php _e( 'Featured Post', 'twentyeleven' ); ?></h1>
|
|
|
|
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
|
|
|
// Let's roll.
|
|
|
|
while ( $featured->have_posts() ) :
|
|
|
|
$featured->the_post();
|
|
|
|
|
|
|
|
// Increase the counter.
|
|
|
|
$counter_slider++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We're going to add a class to our featured post for featured images
|
|
|
|
* by default it'll have the feature-text class.
|
|
|
|
*/
|
|
|
|
$feature_class = 'feature-text';
|
|
|
|
|
|
|
|
if ( has_post_thumbnail() ) {
|
|
|
|
// ... but if it has a featured image let's add some class
|
|
|
|
$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 ) {
|
|
|
|
// If bigger, let's add a BIGGER class. It's EXTRA classy now.
|
|
|
|
$feature_class = 'feature-image large';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
2011-06-11 01:07:18 -04:00
|
|
|
|
2015-01-21 19:42:23 -05:00
|
|
|
<section class="featured-post <?php echo esc_attr( $feature_class ); ?>" id="featured-post-<?php echo esc_attr( $counter_slider ); ?>">
|
2011-06-11 11:44:06 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
<?php
|
2018-08-16 21:51:36 -04:00
|
|
|
/*
|
|
|
|
* If the thumbnail is as big as the header image
|
|
|
|
* make it a large featured post, otherwise render it small
|
|
|
|
*/
|
|
|
|
if ( has_post_thumbnail() ) {
|
|
|
|
if ( $image[1] >= $header_image_width ) {
|
|
|
|
$thumbnail_size = 'large-feature';
|
|
|
|
} else {
|
|
|
|
$thumbnail_size = 'small-feature';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_post_thumbnail( $thumbnail_size ); ?></a>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<?php get_template_part( 'content', 'featured' ); ?>
|
2011-06-11 01:07:18 -04:00
|
|
|
</section>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php endwhile; ?>
|
2011-04-28 20:19:02 -04:00
|
|
|
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
|
|
|
// Show slider only if we have more than one featured post.
|
|
|
|
if ( $featured->post_count > 1 ) :
|
|
|
|
?>
|
2017-11-30 18:11:00 -05:00
|
|
|
<nav class="feature-slider">
|
2011-04-28 20:19:02 -04:00
|
|
|
<ul>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2017-11-30 18:11:00 -05:00
|
|
|
|
2018-08-16 21:51:36 -04:00
|
|
|
// 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++;
|
|
|
|
if ( 1 == $counter_slider ) {
|
|
|
|
$class = ' class="active"';
|
|
|
|
} else {
|
|
|
|
$class = '';
|
|
|
|
}
|
|
|
|
?>
|
2017-11-30 18:11:00 -05:00
|
|
|
<li><a href="#featured-post-<?php echo esc_attr( $counter_slider ); ?>" title="<?php echo esc_attr( sprintf( __( 'Featuring: %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>"<?php echo $class; ?>></a></li>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php endwhile; ?>
|
2011-04-28 20:19:02 -04:00
|
|
|
</ul>
|
2017-11-30 18:11:00 -05:00
|
|
|
</nav>
|
|
|
|
<?php endif; // End check for more than one sticky post. ?>
|
|
|
|
</div><!-- .featured-posts -->
|
|
|
|
<?php endif; // End check for published posts. ?>
|
2011-05-09 18:54:55 -04:00
|
|
|
<?php endif; // End check for sticky posts. ?>
|
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(
|
2017-11-30 18:11:00 -05:00
|
|
|
'order' => 'DESC',
|
|
|
|
'post__not_in' => get_option( 'sticky_posts' ),
|
|
|
|
'tax_query' => array(
|
2011-04-20 17:46:33 -04:00
|
|
|
array(
|
|
|
|
'taxonomy' => 'post_format',
|
2017-11-30 18:11:00 -05:00
|
|
|
'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ),
|
|
|
|
'field' => 'slug',
|
2011-04-20 17:46:33 -04:00
|
|
|
'operator' => 'NOT IN',
|
|
|
|
),
|
|
|
|
),
|
2011-06-10 16:14:59 -04:00
|
|
|
'no_found_rows' => true,
|
2011-04-20 17:46:33 -04:00
|
|
|
);
|
2011-06-11 01:07:18 -04:00
|
|
|
|
2011-04-28 20:19:02 -04:00
|
|
|
// Our new query for the Recent Posts section.
|
2011-06-10 23:44:42 -04:00
|
|
|
$recent = new WP_Query( $recent_args );
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-06-11 01:07:18 -04:00
|
|
|
// The first Recent post is displayed normally
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( $recent->have_posts() ) :
|
|
|
|
$recent->the_post();
|
2011-06-11 01:07:18 -04:00
|
|
|
|
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-06-11 01:07:18 -04:00
|
|
|
get_template_part( 'content', get_post_format() );
|
|
|
|
|
|
|
|
echo '<ol class="other-recent-posts">';
|
|
|
|
|
|
|
|
endif;
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-06-11 01:07:18 -04:00
|
|
|
// For all other recent posts, just display the title and comment status.
|
2017-11-30 18:11:00 -05:00
|
|
|
while ( $recent->have_posts() ) :
|
|
|
|
$recent->the_post();
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-06-11 01:07:18 -04:00
|
|
|
<li class="entry-title">
|
2013-04-29 12:57:30 -04:00
|
|
|
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
|
2011-06-11 01:07:18 -04:00
|
|
|
<span class="comments-link">
|
2011-06-27 16:24:23 -04:00
|
|
|
<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentyeleven' ) . '</span>', __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?>
|
2011-06-11 01:07:18 -04:00
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2011-04-20 17:46:33 -04:00
|
|
|
endwhile;
|
2011-04-26 14:34:52 -04:00
|
|
|
|
2011-06-11 01:07:18 -04:00
|
|
|
// If we had some posts, close the <ol>
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( $recent->post_count > 0 ) {
|
2011-06-11 01:07:18 -04:00
|
|
|
echo '</ol>';
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2011-06-11 01:07:18 -04:00
|
|
|
?>
|
2011-05-09 18:54:55 -04:00
|
|
|
</section><!-- .recent-posts -->
|
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
|
2017-11-30 18:11:00 -05:00
|
|
|
the_widget(
|
2018-08-16 21:51:36 -04:00
|
|
|
'Twenty_Eleven_Ephemera_Widget',
|
|
|
|
'',
|
|
|
|
array(
|
2017-11-30 18:11:00 -05:00
|
|
|
'before_title' => '<h3 class="widget-title">',
|
|
|
|
'after_title' => '</h3>',
|
|
|
|
)
|
|
|
|
);
|
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 -->
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
<?php get_footer(); ?>
|