Skip to content

Commit 389a3ec

Browse files
committed
Template parts
1 parent e444f2d commit 389a3ec

File tree

13 files changed

+147
-252
lines changed

13 files changed

+147
-252
lines changed

archive.php

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,8 @@
66

77
<main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
88

9-
<?php
10-
the_archive_title( '<h1 class="page-title">', '</h1>' );
11-
the_archive_description( '<div class="taxonomy-description">', '</div>' );
12-
?>
13-
14-
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
15-
16-
<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article">
17-
18-
<header class="entry-header article-header">
19-
20-
<h3 class="h2 entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
21-
<p class="byline entry-meta vcard">
22-
<?php printf( __( 'Posted', 'templatetheme' ).' %1$s %2$s',
23-
/* the time the post was published */
24-
'<time class="updated entry-time" datetime="' . get_the_time('Y-m-d') . '" itemprop="datePublished">' . get_the_time(get_option('date_format')) . '</time>',
25-
/* the author of the post */
26-
'<span class="by">'.__('by', 'templatetheme').'</span> <span class="entry-author author" itemprop="author" itemscope itemptype="http://schema.org/Person">' . get_the_author_link( get_the_author_meta( 'ID' ) ) . '</span>'
27-
); ?>
28-
</p>
29-
30-
</header>
31-
32-
<section class="entry-content cf">
33-
34-
<?php the_post_thumbnail( 'template-thumb-300' ); ?>
35-
36-
<?php the_excerpt(); ?>
37-
38-
</section>
39-
40-
<footer class="article-footer">
41-
42-
</footer>
43-
44-
</article>
45-
46-
<?php endwhile; ?>
47-
48-
<?php template_page_navi(); ?>
49-
50-
<?php else : ?>
51-
52-
<article id="post-not-found" class="hentry cf">
53-
<header class="article-header">
54-
<h1><?php _e( 'Oops, Post Not Found!', 'templatetheme' ); ?></h1>
55-
</header>
56-
<section class="entry-content">
57-
<p><?php _e( 'Uh Oh. Something is missing. Try double checking things.', 'templatetheme' ); ?></p>
58-
</section>
59-
<footer class="article-footer">
60-
<p><?php _e( 'This is the error message in the archive.php template.', 'templatetheme' ); ?></p>
61-
</footer>
62-
</article>
63-
64-
<?php endif; ?>
9+
<?php // Edit the loop in /templates/archive-loop. Or roll your own. ?>
10+
<?php get_template_part( 'templates/archive', 'loop'); ?>
6511

6612
</main>
6713

functions.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,54 @@ function template_load_dashicons() {
782782
wp_enqueue_style( 'dashicons' );
783783
}
784784

785+
786+
787+
788+
if ( ! function_exists( 'template_posted_on' ) ) :
789+
/**
790+
* Prints HTML with meta information for the current post-date/time and author.
791+
*/
792+
function template_posted_on() {
793+
794+
// Get the author name; wrap it in a link.
795+
$byline = sprintf(
796+
/* translators: %s: post author */
797+
__( 'by %s', 'templatetheme' ),
798+
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . get_the_author() . '</a></span>'
799+
);
800+
801+
// Finally, let's write all of this to the page.
802+
echo '<span class="posted-on">' . template_time_link() . '</span><span class="byline"> ' . $byline . '</span>';
803+
}
804+
endif;
805+
806+
807+
if ( ! function_exists( 'template_time_link' ) ) :
808+
/**
809+
* Gets a nicely formatted string for the published date.
810+
*/
811+
function template_time_link() {
812+
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
813+
// if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
814+
// $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
815+
// }
816+
817+
$time_string = sprintf( $time_string,
818+
get_the_date( DATE_W3C ),
819+
get_the_date(),
820+
get_the_modified_date( DATE_W3C ),
821+
get_the_modified_date()
822+
);
823+
824+
// Wrap the time string in a link, and preface it with 'Posted on'.
825+
return sprintf(
826+
/* translators: %s: post date */
827+
__( '<span class="screen-reader-text">Posted on</span> %s', 'twentyseventeen' ),
828+
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
829+
);
830+
}
831+
endif;
832+
785833
/*****************************************
786834
* LET'S ROCK SOME TEMPLATE THEME OPTIONS *
787835

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
<?php endwhile; ?>
4747

48-
<?php bones_page_navi(); ?>
48+
<?php template_page_navi(); ?>
4949

5050
<?php else : ?>
5151

page-custom.php

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
*
1313
* Convenience, look it up.
1414
*
15-
* Remember to keep the markup and content separate. I've removed the byline, link
16-
* pages and tags because who really uses those?
15+
* Remember to keep the markup and content separate.
1716
*
1817
* For more info: http://codex.wordpress.org/Page_Templates
1918
*
@@ -29,47 +28,8 @@
2928

3029
<main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
3130

32-
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
33-
34-
<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
35-
36-
<header class="article-header">
37-
38-
<h1 class="page-title"><?php the_title(); ?></h1>
39-
40-
</header>
41-
42-
<section class="entry-content cf" itemprop="articleBody">
43-
<?php
44-
// the content (pretty self explanatory huh)
45-
the_content();
46-
?>
47-
</section>
48-
49-
50-
<footer class="article-footer">
51-
52-
</footer>
53-
54-
<?php comments_template(); ?>
55-
56-
</article>
57-
58-
<?php endwhile; else : ?>
59-
60-
<article id="post-not-found" class="hentry cf">
61-
<header class="article-header">
62-
<h1><?php _e( 'Oops, Post Not Found!', 'templatetheme' ); ?></h1>
63-
</header>
64-
<section class="entry-content">
65-
<p><?php _e( 'Uh Oh. Something is missing. Try double checking things.', 'templatetheme' ); ?></p>
66-
</section>
67-
<footer class="article-footer">
68-
<p><?php _e( 'This is the error message in the page-custom.php template.', 'templatetheme' ); ?></p>
69-
</footer>
70-
</article>
71-
72-
<?php endif; ?>
31+
<?php // Edit the loop in /templates/loop. Or roll your own. ?>
32+
<?php get_template_part( 'templates/loop'); ?>
7333

7434
</main>
7535

page-full.php

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
/*
33
Template Name: Full Width Page
4+
*
5+
* No Sidebar on this page.
46
*/
57
?>
68

@@ -12,66 +14,13 @@
1214

1315
<main id="main" class="m-all t-all d-all cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
1416

15-
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
16-
17-
<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
18-
19-
<header class="article-header">
20-
21-
<h1 class="page-title"><?php the_title(); ?></h1>
22-
23-
<p class="byline entry-meta vcard">
24-
25-
<?php // the post time ?>
26-
<time class="entry-date" datetime="<?php the_date('c'); ?>" itemprop="datePublished" pubdate>Published: <?php echo the_time( 'l, F jS, Y '); ?>at <?php echo the_time( 'g:ia' ); ?></time>
27-
28-
<?php // the author of the post ?>
29-
<span class="by">by </span> <span class="entry-author author" itemprop="author" itemscope itemptype="http://schema.org/Person"><?php echo get_the_author_link( get_the_author_meta( 'ID' ) ); ?></span>
30-
31-
</p>
32-
33-
</header>
34-
35-
<section class="entry-content cf" itemprop="articleBody">
36-
<?php
37-
// the content (pretty self explanatory huh)
38-
the_content();
39-
40-
?>
41-
</section>
42-
43-
44-
<footer class="article-footer">
45-
46-
47-
48-
</footer>
49-
50-
51-
52-
</article>
53-
54-
<?php endwhile; else : ?>
55-
56-
<article id="post-not-found" class="hentry cf">
57-
<header class="article-header">
58-
<h1><?php _e( 'Oops, Post Not Found!', 'templatetheme' ); ?></h1>
59-
</header>
60-
<section class="entry-content">
61-
<p><?php _e( 'Uh Oh. Something is missing. Try double checking things.', 'templatetheme' ); ?></p>
62-
</section>
63-
<footer class="article-footer">
64-
<p><?php _e( 'This is the error message in the page-custom.php template.', 'templatetheme' ); ?></p>
65-
</footer>
66-
</article>
67-
68-
<?php endif; ?>
17+
<?php // Edit the loop in /templates/loop. Or roll your own. ?>
18+
<?php get_template_part( 'templates/loop'); ?>
6919

7020
</main>
7121

7222
</div>
7323

7424
</div>
7525

76-
7726
<?php get_footer(); ?>

page-sidebar.php

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,8 @@
1919

2020
<main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
2121

22-
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
23-
24-
<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
25-
26-
<header class="article-header">
27-
28-
<h1 class="page-title"><?php the_title(); ?></h1>
29-
30-
</header>
31-
32-
<section class="entry-content cf" itemprop="articleBody">
33-
<?php
34-
// the content (pretty self explanatory huh)
35-
the_content();
36-
?>
37-
</section>
38-
39-
40-
<footer class="article-footer">
41-
42-
</footer>
43-
44-
<?php comments_template(); ?>
45-
46-
</article>
47-
48-
<?php endwhile; else : ?>
49-
50-
<article id="post-not-found" class="hentry cf">
51-
<header class="article-header">
52-
<h1><?php _e( 'Oops, Post Not Found!', 'templatetheme' ); ?></h1>
53-
</header>
54-
<section class="entry-content">
55-
<p><?php _e( 'Uh Oh. Something is missing. Try double checking things.', 'templatetheme' ); ?></p>
56-
</section>
57-
<footer class="article-footer">
58-
<p><?php _e( 'This is the error message in the page-custom.php template.', 'templatetheme' ); ?></p>
59-
</footer>
60-
</article>
61-
62-
<?php endif; ?>
22+
<?php // Edit the loop in /templates/loop. Or roll your own. ?>
23+
<?php get_template_part( 'templates/loop'); ?>
6324

6425
</main>
6526

@@ -69,5 +30,4 @@
6930

7031
</div>
7132

72-
7333
<?php get_footer(); ?>

page.php

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,8 @@
66

77
<main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
88

9-
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
10-
11-
<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
12-
13-
<header class="article-header">
14-
15-
<h1 class="page-title" itemprop="headline"><?php the_title(); ?></h1>
16-
17-
<p class="byline entry-meta vcard">
18-
19-
<?php // the post time ?>
20-
<time class="entry-date" datetime="<?php the_date('c'); ?>" itemprop="datePublished" pubdate>Published: <?php echo the_time( 'l, F jS, Y '); ?>at <?php echo the_time( 'g:ia' ); ?></time>
21-
22-
<?php // the author of the post ?>
23-
<span class="by">by </span> <span class="entry-author author" itemprop="author" itemscope itemptype="http://schema.org/Person"><?php echo get_the_author_link( get_the_author_meta( 'ID' ) ); ?></span>
24-
25-
</p>
26-
27-
</header> <?php // end article header ?>
28-
29-
<section class="entry-content cf" itemprop="articleBody">
30-
<?php
31-
// the content (pretty self explanatory huh)
32-
the_content();
33-
?>
34-
</section> <?php // end article section ?>
35-
36-
<footer class="article-footer cf">
37-
38-
</footer>
39-
40-
<?php comments_template(); ?>
41-
42-
</article>
43-
44-
<?php endwhile; endif; ?>
9+
<?php // Edit the loop in /templates/loop. Or roll your own. ?>
10+
<?php get_template_part( 'templates/loop'); ?>
4511

4612
</main>
4713

readme.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h2 id="recommendedplugins">Recommended Plugins</h2>
5050
- Plugin Organizer: https://wordpress.org/plugins/plugin-organizer/
5151
- WP Migrate DB Pro: https://deliciousbrains.com/wp-migrate-db-pro/</p>
5252

53-
<h3 id="otherstuffs">Other stuffs</h3>
53+
<h2 id="otherstuffs">Other stuffs</h2>
5454

5555
<p>Designed by Joshua Michaels for studio.bio: http://studio.bio/template
5656
With help from Jon Iler.</p>

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Some of the stuff in Template references plugins that I use with just about ever
4141
- Plugin Organizer: https://wordpress.org/plugins/plugin-organizer/
4242
- WP Migrate DB Pro: https://deliciousbrains.com/wp-migrate-db-pro/
4343

44-
###Other stuffs
44+
## Other stuffs
4545
Designed by Joshua Michaels for studio.bio: http://studio.bio/template
4646
With help from Jon Iler.
4747

0 commit comments

Comments
 (0)