Skip to content

Instantly share code, notes, and snippets.

@y-krn
Created December 9, 2016 09:16
Show Gist options
  • Save y-krn/264b076b98bae68b3d30e1e34ac6dc25 to your computer and use it in GitHub Desktop.
Save y-krn/264b076b98bae68b3d30e1e34ac6dc25 to your computer and use it in GitHub Desktop.
AMP Custom Template Single.php
<!doctype html>
<html amp <?php echo AMP_HTML_Utils::build_attributes_string( $this->get( 'html_tag_attributes' ) ); ?>>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<?php do_action( 'amp_post_template_head', $this ); ?>
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<style amp-custom>
<?php $this->load_parts( array( 'style' ) ); ?>
<?php do_action( 'amp_post_template_css', $this ); ?>
</style>
</head>
<body class="<?php echo esc_attr( $this->get( 'body_class' ) ); ?>">
<?php $this->load_parts( array( 'header-bar' ) ); ?>
<article class="amp-wp-article">
<header class="amp-wp-article-header">
<h1 class="amp-wp-title"><?php echo wp_kses_data( $this->get( 'post_title' ) ); ?></h1>
<?php //$this->load_parts( apply_filters( 'amp_post_article_header_meta', array( 'meta-author', 'meta-time' ) ) ); ?>
</header>
<ol class="entry-header list-inline text-xs-center">
<small class="text-muted">
<li class="list-inline-item sr-only"><span class="post-author vcard author"><span class="fn"><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author(); ?></a></span></span></li>
<?php if ( get_the_modified_date( 'Y/n/j' ) != get_the_time( 'Y/n/j' ) ) : ?>
<li class="list-inline-item"><i class="fa fa-clock-o"></i> 公開日:<?php echo get_post_time( 'Y/m/d' ); ?></li>
<li class="list-inline-item"><i class="fa fa-clock-o"></i> 更新日:<time itemprop="dateModified" datetime="<?php echo get_the_modified_date( 'Y-m-d' ); ?>" class="date updated"><?php the_modified_date( 'Y/m/d' ) ?></time></li>
<?php else : ?>
<li class="list-inline-item"><i class="fa fa-clock-o"></i> 公開日:<time itemprop="datePublished" datetime="<?php echo get_post_time( 'Y-m-d' ); ?>" class="date published updated"><?php echo get_post_time( 'Y/m/d' ); ?></time></li>
<?php endif; ?>
<li class="list-inline-item"><i class="fa fa-folder-open-o"></i> <?php the_category( ',' ); ?></li>
<?php if ( has_tag() ) : ?>
<li class="list-inline-item"><i class="fa fa-tags"></i> <?php the_tags( '' ); ?></li>
<?php endif; ?>
</small>
</ol>
<amp-ad
layout="fixed-height"
height=100
type="adsense"
data-ad-client="ca-pub-xxxx"
data-ad-slot="yyyy">
</amp-ad>
<div class="amp-wp-article-content">
<div class="btn-group btn-group-justified">
<div class="btn-group"><a href="http://b.hatena.ne.jp/entry/<?php the_permalink(); ?>" class="btn btn-hatena"><b>B!</b></a></div>
<div class="btn-group"><a href="https://twitter.com/share?url=<?php the_permalink(); ?>&amp;text=<?php the_title(); ?>&amp;via=ottanxyz" class="btn btn-twitter"><i class="fa fa-twitter"></i></a></div>
<div class="btn-group"><a href="http://www.facebook.com/share.php?u=<?php the_permalink(); ?>" class="btn btn-facebook"><i class="fa fa-facebook"></i></a></div>
<div class="btn-group"><a href="https://plus.google.com/share?url=<?php the_permalink(); ?>" class="btn btn-googleplus"><i class="fa fa-google-plus"></i></a></div>
<div class="btn-group"><a href="http://getpocket.com/edit?url=<?php the_permalink(); ?>&amp;title=<?php the_title(); ?>" class="btn btn-pocket"><i class="fa fa-get-pocket"></i></a></div>
</div>
<?php echo $this->get( 'post_amp_content' ); // amphtml content; no kses ?>
</div>
<amp-ad
layout="responsive"
width=300
height=250
type="adsense"
data-ad-client="ca-pub-xxxx"
data-ad-slot="zzzz">
</amp-ad>
<amp-ad
layout="responsive"
width=300
height=250
type="adsense"
data-ad-client="ca-pub-xxxx"
data-ad-slot="wwww">
</amp-ad>
<footer class="amp-wp-article-footer">
<?php //$this->load_parts( apply_filters( 'amp_post_article_footer_meta', array( 'meta-taxonomy', 'meta-comments-link' ) ) ); ?>
</footer>
</article>
<?php $this->load_parts( array( 'footer' ) ); ?>
<?php do_action( 'amp_post_template_footer', $this ); ?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment