2011-04-20 23:46:33 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Template Name: Showcase Template
|
2013-09-25 18:50:11 +02:00
|
|
|
*
|
|
|
|
* Description: A Page Template that showcases Sticky Posts, Asides, and Blog Posts.
|
2011-04-20 23:46:33 +02:00
|
|
|
*
|
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
|
|
|
*/
|
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Enqueue showcase script for the slider.
|
2023-03-07 17:27:18 +01:00
|
|
|
wp_enqueue_script( 'twentyeleven-showcase', get_template_directory_uri() . '/js/showcase.js', array( 'jquery' ), '20211130' );
|
2011-04-29 02:19:02 +02:00
|
|
|
|
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
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
<?php
|
|
|
|
while ( have_posts() ) :
|
|
|
|
the_post();
|
|
|
|
?>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2013-10-09 22:39:09 +02:00
|
|
|
/*
|
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.
|
|
|
|
*/
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( '' !== get_the_content() ) {
|
2018-08-17 03:51:36 +02:00
|
|
|
get_template_part( 'content', 'intro' );
|
|
|
|
}
|
|
|
|
?>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-11-21 17:20:49 +01:00
|
|
|
<?php endwhile; ?>
|
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
<?php
|
2013-10-09 22:39:09 +02:00
|
|
|
/*
|
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.
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! empty( $sticky ) ) :
|
2011-06-09 18:39:40 +02:00
|
|
|
|
2011-04-20 23:46:33 +02:00
|
|
|
$featured_args = array(
|
2017-12-01 00:11:00 +01:00
|
|
|
'post__in' => $sticky,
|
|
|
|
'post_status' => 'publish',
|
2011-05-10 00:54:55 +02:00
|
|
|
'posts_per_page' => 10,
|
2017-12-01 00:11:00 +01: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-11 17:44:06 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Proceed only if published posts exist.
|
2011-06-09 18:53:01 +02:00
|
|
|
if ( $featured->have_posts() ) :
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
/*
|
|
|
|
* We will need to count featured posts starting from zero
|
|
|
|
* to create the slider navigation.
|
|
|
|
*/
|
|
|
|
$counter_slider = 0;
|
2011-04-29 02:19:02 +02:00
|
|
|
|
2017-12-01 00:11:00 +01: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-17 03:51:36 +02:00
|
|
|
?>
|
2011-04-29 02:19:02 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
<div class="featured-posts">
|
2011-04-29 02:19:02 +02:00
|
|
|
<h1 class="showcase-heading"><?php _e( 'Featured Post', 'twentyeleven' ); ?></h1>
|
|
|
|
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
|
|
|
// Let's roll.
|
|
|
|
while ( $featured->have_posts() ) :
|
|
|
|
$featured->the_post();
|
|
|
|
|
|
|
|
// Increase the counter.
|
2023-09-09 11:28:26 +02:00
|
|
|
++$counter_slider;
|
2018-08-17 03:51:36 +02:00
|
|
|
|
|
|
|
/*
|
2020-01-29 01:45:18 +01:00
|
|
|
* We're going to add a class to our featured post for featured images.
|
|
|
|
* By default it will have the feature-text class.
|
2018-08-17 03:51:36 +02:00
|
|
|
*/
|
|
|
|
$feature_class = 'feature-text';
|
|
|
|
|
|
|
|
if ( has_post_thumbnail() ) {
|
2020-01-29 01:45:18 +01:00
|
|
|
// ...but if it has a featured image let's add some class.
|
2018-08-17 03:51:36 +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 ) {
|
|
|
|
// If bigger, let's add a BIGGER class. It's EXTRA classy now.
|
|
|
|
$feature_class = 'feature-image large';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
2011-06-11 07:07:18 +02:00
|
|
|
|
2015-01-22 01:42:23 +01:00
|
|
|
<section class="featured-post <?php echo esc_attr( $feature_class ); ?>" id="featured-post-<?php echo esc_attr( $counter_slider ); ?>">
|
2011-06-11 17:44:06 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
<?php
|
2018-08-17 03:51:36 +02: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';
|
|
|
|
}
|
2019-07-05 10:04:57 +02:00
|
|
|
|
2019-09-03 02:41:05 +02:00
|
|
|
/* translators: %s: Post title. */
|
2019-07-05 10:04:57 +02:00
|
|
|
$title = sprintf( __( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) );
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2019-07-05 10:04:57 +02:00
|
|
|
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( $title ); ?>" rel="bookmark"><?php the_post_thumbnail( $thumbnail_size ); ?></a>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<?php get_template_part( 'content', 'featured' ); ?>
|
2011-06-11 07:07:18 +02:00
|
|
|
</section>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php endwhile; ?>
|
2011-04-29 02:19:02 +02:00
|
|
|
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
|
|
|
// Show slider only if we have more than one featured post.
|
|
|
|
if ( $featured->post_count > 1 ) :
|
|
|
|
?>
|
2017-12-01 00:11:00 +01:00
|
|
|
<nav class="feature-slider">
|
2011-04-29 02:19:02 +02:00
|
|
|
<ul>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2017-12-01 00:11:00 +01:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Reset the counter so that we end up with matching elements.
|
2018-08-17 03:51:36 +02:00
|
|
|
$counter_slider = 0;
|
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Begin from zero.
|
2018-08-17 03:51:36 +02:00
|
|
|
rewind_posts();
|
|
|
|
|
|
|
|
// Let's roll again.
|
|
|
|
while ( $featured->have_posts() ) :
|
|
|
|
$featured->the_post();
|
2023-09-09 11:28:26 +02:00
|
|
|
++$counter_slider;
|
2023-02-24 07:23:23 +01:00
|
|
|
if ( 1 === $counter_slider ) {
|
2018-08-17 03:51:36 +02:00
|
|
|
$class = ' class="active"';
|
|
|
|
} else {
|
|
|
|
$class = '';
|
|
|
|
}
|
2019-07-05 10:04:57 +02:00
|
|
|
|
2019-09-03 02:41:05 +02:00
|
|
|
/* translators: %s: Post title. */
|
2019-07-05 10:04:57 +02:00
|
|
|
$title = sprintf( __( 'Featuring: %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) );
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2022-11-26 23:39:10 +01:00
|
|
|
<li><a href="#featured-post-<?php echo esc_attr( $counter_slider ); ?>"<?php echo $class; ?>><span class="feature-slider-tooltip" aria-hidden="true" title="<?php echo esc_attr( $title ); ?>"></span><span class="screen-reader-text"><?php echo esc_html( $title ); ?></span></a></li>
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php endwhile; ?>
|
2011-04-29 02:19:02 +02:00
|
|
|
</ul>
|
2017-12-01 00:11:00 +01:00
|
|
|
</nav>
|
|
|
|
<?php endif; // End check for more than one sticky post. ?>
|
|
|
|
</div><!-- .featured-posts -->
|
|
|
|
<?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(
|
2017-12-01 00:11:00 +01:00
|
|
|
'order' => 'DESC',
|
|
|
|
'post__not_in' => get_option( 'sticky_posts' ),
|
|
|
|
'tax_query' => array(
|
2011-04-20 23:46:33 +02:00
|
|
|
array(
|
|
|
|
'taxonomy' => 'post_format',
|
2017-12-01 00:11:00 +01:00
|
|
|
'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ),
|
|
|
|
'field' => 'slug',
|
2011-04-20 23:46:33 +02:00
|
|
|
'operator' => 'NOT IN',
|
|
|
|
),
|
|
|
|
),
|
2011-06-10 22:14:59 +02:00
|
|
|
'no_found_rows' => true,
|
2011-04-20 23:46:33 +02:00
|
|
|
);
|
2011-06-11 07:07:18 +02:00
|
|
|
|
2011-04-29 02:19:02 +02:00
|
|
|
// Our new query for the Recent Posts section.
|
2011-06-11 05:44:42 +02:00
|
|
|
$recent = new WP_Query( $recent_args );
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// The first Recent post is displayed normally.
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $recent->have_posts() ) :
|
|
|
|
$recent->the_post();
|
2011-06-11 07:07:18 +02:00
|
|
|
|
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-06-11 07:07:18 +02:00
|
|
|
get_template_part( 'content', get_post_format() );
|
|
|
|
|
|
|
|
echo '<ol class="other-recent-posts">';
|
|
|
|
|
|
|
|
endif;
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-06-11 07:07:18 +02:00
|
|
|
// For all other recent posts, just display the title and comment status.
|
2017-12-01 00:11:00 +01:00
|
|
|
while ( $recent->have_posts() ) :
|
|
|
|
$recent->the_post();
|
2018-08-17 03:51:36 +02:00
|
|
|
?>
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2011-06-11 07:07:18 +02:00
|
|
|
<li class="entry-title">
|
2013-04-29 18:57:30 +02:00
|
|
|
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
|
2011-06-11 07:07:18 +02:00
|
|
|
<span class="comments-link">
|
2011-06-27 22:24:23 +02: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 07:07:18 +02:00
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
|
2018-08-17 03:51:36 +02:00
|
|
|
<?php
|
2011-04-20 23:46:33 +02:00
|
|
|
endwhile;
|
2011-04-26 20:34:52 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// If we had some posts, close the <ol>.
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( $recent->post_count > 0 ) {
|
2011-06-11 07:07:18 +02:00
|
|
|
echo '</ol>';
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2011-06-11 07:07:18 +02:00
|
|
|
?>
|
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
|
2017-12-01 00:11:00 +01:00
|
|
|
the_widget(
|
2018-08-17 03:51:36 +02:00
|
|
|
'Twenty_Eleven_Ephemera_Widget',
|
|
|
|
'',
|
|
|
|
array(
|
2017-12-01 00:11:00 +01:00
|
|
|
'before_title' => '<h3 class="widget-title">',
|
|
|
|
'after_title' => '</h3>',
|
|
|
|
)
|
|
|
|
);
|
2011-04-26 20:34:52 +02:00
|
|
|
?>
|
2011-04-20 23:46:33 +02:00
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
<?php endif; // End sidebar widget area. ?>
|
2011-04-20 23:46:33 +02:00
|
|
|
</div><!-- .widget-area -->
|
|
|
|
|
|
|
|
</div><!-- #content -->
|
|
|
|
</div><!-- #primary -->
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
<?php get_footer(); ?>
|