3
* Custom template tags for Twenty Fourteen
6
* @subpackage Twenty_Fourteen
7
* @since Twenty Fourteen 1.0
10
if ( ! function_exists( 'twentyfourteen_paging_nav' ) ) :
12
* Display navigation to next/previous set of posts when applicable.
14
* @since Twenty Fourteen 1.0
16
* @global WP_Query $wp_query WordPress Query object.
17
* @global WP_Rewrite $wp_rewrite WordPress Rewrite object.
19
function twentyfourteen_paging_nav() {
20
global $wp_query, $wp_rewrite;
22
// Don't print empty markup if there's only one page.
23
if ( $wp_query->max_num_pages < 2 ) {
27
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
28
$pagenum_link = html_entity_decode( get_pagenum_link() );
29
$query_args = array();
30
$url_parts = explode( '?', $pagenum_link );
32
if ( isset( $url_parts[1] ) ) {
33
wp_parse_str( $url_parts[1], $query_args );
36
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
37
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
39
$format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
40
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
42
// Set up paginated links.
43
$links = paginate_links( array(
44
'base' => $pagenum_link,
46
'total' => $wp_query->max_num_pages,
49
'add_args' => array_map( 'urlencode', $query_args ),
50
'prev_text' => __( '← Previous', 'twentyfourteen' ),
51
'next_text' => __( 'Next →', 'twentyfourteen' ),
57
<nav class="navigation paging-navigation" role="navigation">
58
<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentyfourteen' ); ?></h1>
59
<div class="pagination loop-pagination">
61
</div><!-- .pagination -->
62
</nav><!-- .navigation -->
68
if ( ! function_exists( 'twentyfourteen_post_nav' ) ) :
70
* Display navigation to next/previous post when applicable.
72
* @since Twenty Fourteen 1.0
74
function twentyfourteen_post_nav() {
75
// Don't print empty markup if there's nowhere to navigate.
76
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
77
$next = get_adjacent_post( false, '', false );
79
if ( ! $next && ! $previous ) {
84
<nav class="navigation post-navigation" role="navigation">
85
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentyfourteen' ); ?></h1>
86
<div class="nav-links">
88
if ( is_attachment() ) :
89
previous_post_link( '%link', __( '<span class="meta-nav">Published In</span>%title', 'twentyfourteen' ) );
91
previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen' ) );
92
next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'twentyfourteen' ) );
95
</div><!-- .nav-links -->
96
</nav><!-- .navigation -->
101
if ( ! function_exists( 'twentyfourteen_posted_on' ) ) :
103
* Print HTML with meta information for the current post-date/time and author.
105
* @since Twenty Fourteen 1.0
107
function twentyfourteen_posted_on() {
108
if ( is_sticky() && is_home() && ! is_paged() ) {
109
echo '<span class="featured-post">' . __( 'Sticky', 'twentyfourteen' ) . '</span>';
112
// Set up and print post meta information.
113
printf( '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a class="url fn n" href="%4$s" rel="author">%5$s</a></span></span>',
114
esc_url( get_permalink() ),
115
esc_attr( get_the_date( 'c' ) ),
116
esc_html( get_the_date() ),
117
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
124
* Find out if blog has more than one category.
126
* @since Twenty Fourteen 1.0
128
* @return boolean true if blog has more than 1 category
130
function twentyfourteen_categorized_blog() {
131
if ( false === ( $all_the_cool_cats = get_transient( 'twentyfourteen_category_count' ) ) ) {
132
// Create an array of all the categories that are attached to posts
133
$all_the_cool_cats = get_categories( array(
137
// Count the number of categories that are attached to the posts
138
$all_the_cool_cats = count( $all_the_cool_cats );
140
set_transient( 'twentyfourteen_category_count', $all_the_cool_cats );
143
if ( 1 !== (int) $all_the_cool_cats ) {
144
// This blog has more than 1 category so twentyfourteen_categorized_blog should return true
147
// This blog has only 1 category so twentyfourteen_categorized_blog should return false
153
* Flush out the transients used in twentyfourteen_categorized_blog.
155
* @since Twenty Fourteen 1.0
157
function twentyfourteen_category_transient_flusher() {
158
// Like, beat it. Dig?
159
delete_transient( 'twentyfourteen_category_count' );
161
add_action( 'edit_category', 'twentyfourteen_category_transient_flusher' );
162
add_action( 'save_post', 'twentyfourteen_category_transient_flusher' );
165
* Display an optional post thumbnail.
167
* Wraps the post thumbnail in an anchor element on index
168
* views, or a div element when on single views.
170
* @since Twenty Fourteen 1.0
172
function twentyfourteen_post_thumbnail() {
173
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
177
if ( is_singular() ) :
180
<div class="post-thumbnail">
182
if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) {
183
the_post_thumbnail( 'twentyfourteen-full-width' );
185
the_post_thumbnail();
192
<a class="post-thumbnail" href="<?php the_permalink(); ?>">
194
if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) {
195
the_post_thumbnail( 'twentyfourteen-full-width' );
197
the_post_thumbnail();
202
<?php endif; // End is_singular()