WP開発環境スターターキット [スラッグ][タクソノミー名][タクソノミー]で検索ファイル名が違っているので自分で設定すべし。
/*
Theme Name: タイトル
Author: GEOCODE
*/
@charset 'UTF-8';
/*=========================================================
*
* Style Index:
* 0. Reset
* 1. Layout
* - Base
* - Header
* - Content
* - Breadcrumb
* - Pagination
* - Anteroposterior
* - Sidebar
* - Footer
* - PageTop
*
* 2. Module
* - Top Image
* - Title
* - Box
* - List
* - Table
* - Form
* - Button
* - Image
* - Link
* - Toggle
*
* 3. Cosmetic
* - Background
* - Figure
* - Decoration
* - Icon
*
* 4. Utility
* - Position
* - Display
* - Margin
* - Padding
* - Width
* - Text
* - Vertical Align
* - WordPress
*
=======================================================
/*---------------------------------------------------------
* 0. Reset
*--------------------------------------------------------*/
* {
box-sizing: border-box;
/* -webkit-text-size-adjust: 100%; */
}
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var, b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
box-sizing: border-box;
margin: 0;
padding: 0;
outline: 0;
border: 0;
background: transparent;
vertical-align: baseline;
}
input[type="button"],input[type="submit"] {
-webkit-appearance: none;
}
label {
cursor: pointer;
}
body {
line-height: 1;
}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section {
display:block;
list-style: none;
}
nav ul {
list-style:none;
}
blockquote, q {
quotes:none;
}
blockquote:before, blockquote:after,q:before, q:after {
content:'';
content:none;
}
a {
margin:0;
padding:0;
background:transparent;
color: #00689a;
vertical-align:baseline;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
ins {
background-color:#ff9;
color:#000;
text-decoration:none;
}
mark {
background-color:#ff9;
color:#000;
font-weight:bold;
font-style:italic;
}
del {
text-decoration: line-through;
}
abbr[title], dfn[title] {
border-bottom:1px dotted;
cursor:help;
}
table {
border-spacing:0;
border-collapse:collapse;
}
hr {
display:block;
margin:1em 0;
padding:0;
height:1px;
border:0;
border-top:1px solid #cccccc;
}
input, select {
vertical-align:middle;
}
input[type="submit"]{
outline: none;
}
select {
margin: 0;
padding: 0;
border: 0;
border-radius: 0;
background: none transparent;
color: inherit;
vertical-align: middle;
font-size: inherit;
}
select {
text-indent: 0.01px;
text-overflow: '';
-moz-appearance: none;
}
select::-ms-expand {
display: none;
}
ul li {
list-style: none;
}
/*---------------------------------------------------------
* 1. Layout
*--------------------------------------------------------*/
/** Base **/
/** Header **/
/** Content **/
/** Breadcrumb **/
/** Pagination **/
/** Anteroposterior **/
/** Sidebar **/
/** Footer **/
/** PageTop **/
/*---------------------------------------------------------
* 2. Module
*--------------------------------------------------------*/
/* Top Image */
/** Title **/
/** Box **/
/* List */
/** Table **/
/** Button **/
/** Image **/
/* link */
/* Toggle */
/*---------------------------------------------------------
* 3. Cosmetic
*--------------------------------------------------------*/
/* Background */
/* Figure */
/* Decoration */
/* Icon */
/*---------------------------------------------------------
* 4. Utility
*--------------------------------------------------------*/
/* Position */
/* Display */
/* Margin */
/* Padding */
/* Width */
/* Text */
/* Vertical Align */
/* WordPress */
<?php get_header(); ?>
<div class="">
<?php if(have_posts()): ?>
<?php while(have_posts()): the_post(); ?>
// <?php $terms = get_the_terms($post->ID, '[タクソノミー名]'); ?>
<?php $cat_name = $terms[0]->name; ?>
<?php $slug_name = $terms[0]->slug; ?>
<h1><span class="<?php echo $slug_name; ?>"></span><?php the_title(); ?></h1>
<p><?php the_time('Y.m.d'); ?></p>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php
if( get_previous_post() || get_next_post() ):
$prev_post = get_previous_post();
$next_post = get_next_post();
?>
<ul class="pager_news_detail">
<?php if( !empty($prev_post) ): ?>
<li class="prev"><a href="<?php echo get_permalink($prev_post->ID ); ?>" class="trans prev">前へ</a></li>
<?php endif; ?>
<li class="curr"><a href="<?php echo get_post_type_archive_link($post->post_type); ?>" class="trans back">新着一覧に戻る</a></li>
<?php if( !empty($next_post) ): ?>
<li class="next"><a href="<?php echo get_permalink($next_post->ID ); ?>" class="trans next">次へ</a></li>
<?php endif; ?>
</ul>
<?php endif; ?>
</div>
<div class="sidebar">
<?php get_template_part("sidebar"); ?>
</div>
<?php get_footer(); ?>
<div class="">
<h2>カテゴリー別</h2>
<ul>
<!-- <?php wp_list_categories('title_li=&taxonomy=[タクソノミー名]'); ?> -->
</ul>
</div>
<div class="">
<h2>月別</h2>
<ul>
<!-- <?php wp_get_archives('post_type=[スラッグ]'); ?> -->
</ul>
</div>
<?php get_header(); ?>
<?php get_footer(); ?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>タイトル</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url') ?>">
<?php wp_head(); ?>
</head>
<body>
<?php
// Custom Post Type
// add_action('init', '[スラッグ]');
// function [スラッグ](){
// $args = array(
// 'label' => '[表示されるタイトル]',
// 'public' => true,
// 'publicly_queryable' => true,
// 'show_ui' => true,
// 'query_var' => true,
// 'rewrite' => true,
// 'has_archive' => true,
// 'capability_type' => 'post',
// 'hierarchical' => false,
// 'menu_position' => 5,
// 'supports' => array('title','editor','thumbnail','revisions'),
// 'rewrite' => array(
// 'slug' => '[スラッグ]',
// 'with_front' => false
// ),
// 'menu_icon' => 'dashicons-format-aside',
// );
// register_post_type('[スラッグ]',$args);
// //分類を追加
// $args = array(
// 'label' => 'カテゴリー',
// 'public' => true,
// 'show_ui' => true,
// 'hierarchical' => true,
// 'query_var'=> true,
// 'rewrite' => array(
// 'slug' => '[スラッグ]/category',
// 'with_front' => false
// )
// );
// register_taxonomy('[タクソノミー名]','[スラッグ]',$args);
// }
// ================= To Delete tags =================
remove_action( 'wp_head', 'feed_links', 2 ); //サイト全体のフィード
remove_action( 'wp_head', 'feed_links_extra', 3 ); //その他のフィード
remove_action( 'wp_head', 'rsd_link' ); //Really Simple Discoveryリンク
remove_action( 'wp_head', 'wlwmanifest_link' ); //Windows Live Writerリンク
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); //前後の記事リンク
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); //ショートリンク
// remove_action( 'wp_head', 'rel_canonical' ); //canonical属性
remove_action( 'wp_head', 'wp_generator' ); //WPバージョン
// ================= Convert Slug =================
// function auto_post_slug( $slug, $post_ID, $post_status, $post_type ) {
// $posttime = get_post_time('Ymd');
// $today = date('Ymd');
// if($today <= $posttime){
// if($post_type == '[スラッグ]') {
// $slug = 'post-' . $post_ID;
// }else if($post_type == '[スラッグ]') {
// $slug = 'post-' . $post_ID;
// }
// }
// return $slug;
// }
// add_filter( 'wp_unique_post_slug', 'auto_post_slug', 10, 4 );
// ================= pagination ====================
function pagination($pages = '', $range = 2){
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) {
$paged = 1;
}
if($pages == '') {
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages) {
$pages = 1;
}
}
if(1 != $pages) {
echo "<div class='pagination pager'><ul>";
//if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo '<a class="first" href="'.get_pagenum_link(1).'">« 最初</a>';
if($paged > 1) {
echo '<li><a class="prev" href="'.get_pagenum_link($paged - 1).'">前へ</a></li>';
}
for ($i=1; $i <= $pages; $i++){
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
echo ($paged == $i)? "<li><span class='current'>".$i."</span></li>":"<li><a href='".get_pagenum_link($i)."' class='trans' >".$i."</a></li>";
}
/*if($i < ($pages - $paged)){
echo ($paged == $i)? "<li><span class='current'>".$i."</span></li>":"<li><a href='".get_pagenum_link($i)."' class='trans' >".$i."</a></li>";
}*/
}
if ($paged < $pages){
echo '<li><a class="trans next" href="'.get_pagenum_link($paged + 1).'">次へ</a></li>';
}
//if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo '<a class="last" href="'.get_pagenum_link($pages).'">最後 »</a>';
echo "</ul></div>\n";
}
}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/index.js"></script>
<?php wp_footer(); ?>
</body>
</html>
<?php get_header(); ?>
<?php if(have_posts()): ?>
<?php while(have_posts()): the_post(); ?>
<?php $terms = get_the_terms($post->ID, '[タクソノミー名]'); ?>
<?php $cat_name = $terms[0]->name; ?>
<?php $slug_name = $terms[0]->slug; ?>
<a href="<?php echo the_permalink(); ?>">
<p><?php the_time('Y.m.d'); ?></p>
<p class="<?php echo $slug_name; ?>"><?php echo $cat_name ?></p>
<p><?php the_title(); ?></p>
<p><?php the_content(); ?></p><br>
</a>
<?php endwhile; ?>
<?php else: ?>
<p>投稿された記事がありません。</p>
<?php endif ?>
<div class="list_pager">
<?php pagination(); ?>
</div>
<?php get_footer(); ?>
標準装備
・アーカイブページ
・シングルページ
・投稿のパーマリンクを自動でポストIDに。
・カテゴリー
・カテゴリーリスト
・月別アーカイブ