カスタム投稿タイプのアイコン情報、ホームページの一覧にカスタム投稿を含める
functions.phpに追加します。
<?php
// 一行目はシンタックスハイライトするために追加しています。
// カスタム投稿タイプとアイコン
$my_post_icon = array(
"travel" => "fa-camera",
"cake" => "fa-birthday-cake",
);
参考
functions.phpGist
記事一覧、個別記事にカスタム投稿タイプ、カテゴリー表示
親テーマから category-link.php をコピーして修正します。
<?php //インデックスページや投稿ページで表示されるカテゴリーリンク
if ( is_category_visible() ): //カテゴリを表示する場合?>
<?php if ( get_the_category() ) : //投稿ページの場合?>
//
// 略
//
<?php else : //カスタム投稿の場合 ?>
<?php global $my_post_icon;
$my_post = get_post_type(get_the_ID()); ?>
<?php if ( isset($my_post, $my_post_icon) ) : ?>
<span class="category">
<?php echo '<span class="fa '.$my_post_icon[$my_post].' fa-fw"></span> '?>
<?php echo '<a href="'.get_post_type_archive_link($my_post).'">'.get_post_type_object($my_post)->label.'</a>' ?></span>
<?php endif; ?>
<?php $taxonomy_names = get_post_taxonomies( get_the_ID() );
$taxonomy_name = null;
foreach ($taxonomy_names as $value)
if(is_taxonomy_hierarchical($value)) // カテゴリの場合
$taxonomy_name = $value; ?>
<?php if ( !empty($taxonomy_name) ) : ?>
<?php $taxonomy_names = get_post_taxonomies( get_the_ID() );?>
<span class="category"><span class="fa fa-folder fa-fw"></span>
<?php echo get_the_term_list( get_the_ID(), $taxonomy_name,'',', ','' ); ?></span>
<?php endif; ?>
<?php endif; ?>
<?php endif; //is_category_visible?>
参考
category-link.phpGist
個別記事にカスタム投稿タグ表示
親テーマから entry-body.php をコピーして修正します。
<?php //投稿本文 ?>
//
// 略
//
<?php if (is_tag_visible()): ?>
<?php if ( get_the_category() ): //投稿ページの場合?>
//
// 略
//
<?php else : //カスタム投稿の場合 ?>
<?php $taxonomy_names = get_post_taxonomies( get_the_ID() );
$taxonomy_name = null;
foreach ($taxonomy_names as $value)
if(!is_taxonomy_hierarchical($value)) // tagの場合
$taxonomy_name = $value; ?>
<?php if ( !empty($taxonomy_name) ) : ?>
<span class="post-tag"><?php echo get_the_term_list( get_the_ID(), $taxonomy_name,'<span class="fa fa-tags fa-fw"></span>',', ','' ); ?></span>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
//
// 略
//
参考
entry-body.phpGist
コメント部分の表示変更
- 通常投稿は公開記事であるため、会員への注意文言追加
- カスタム投稿の記事にて、ログイン中、ログアウトしますか?の表示削除
親テーマから comments-default.php をコピーして修正します。
<!-- comment area -->
<div id="comment-area">
<?php
//
// 略
//
// ここからコメントフォーム
if( is_user_logged_in() ) {//ログインしている場合
if( is_singular( 'post' ) )
$args = array(
'title_reply' => get_theme_text_comment_reply_title() . '(この記事のコメントは会員以外の方も閲覧できますので注意してください)',//コメントをどうぞ
'label_submit' => get_theme_text_comment_submit_label(),//コメントを送信
);
else $args = array(
'title_reply' => get_theme_text_comment_reply_title(),//コメントをどうぞ
'label_submit' => get_theme_text_comment_submit_label(),//コメントを送信
'must_log_in' => '<p class="must-log-in"></p>',
'logged_in_as' => '<p class="logged-in-as"></p>',
);
} else //ログインしていない場合、カスタム投稿はアクセス制限しているので判断は不要
$args = array(
'title_reply' => get_theme_text_comment_reply_title(),//コメントをどうぞ
'label_submit' => get_theme_text_comment_submit_label(),//コメントを送信
);
echo '<aside>';
//
// 略
//
参考
comments-default.phpGist
親テーマから comments-thread.php をコピーして修正します。
<div id="comments-thread">
<?php
//
// 略
//
} else {//コメント欄を表示
if( is_user_logged_in() ) {//ログインしている場合
if( is_singular( 'post' ) )
$args = array(
'title_reply' => get_theme_text_comment_reply_title() . '(この記事のコメントは会員以外の方も閲覧できますので注意してください)',//コメントをどうぞ
'label_submit' => get_theme_text_comment_submit_label(),//コメントを送信
);
else $args = array(
'title_reply' => get_theme_text_comment_reply_title(),//コメントをどうぞ
'label_submit' => get_theme_text_comment_submit_label(),//コメントを送信
'must_log_in' => '<p class="must-log-in"></p>',
'logged_in_as' => '<p class="logged-in-as"></p>',
);
} else //ログインしていない場合、カスタム投稿はアクセス制限しているので判断は不要
$args = array(
'title_reply' => get_theme_text_comment_reply_title(),//コメントをどうぞ
'label_submit' => get_theme_text_comment_submit_label(),//コメントを送信
);
echo '<aside>';
//
// 略
//
参考
comments-thread.phpGist
Monappy: MBDQ39VHypMQwfyR8SshuHvfPNUz321F6B

モナゲ(tipmona)ってなに?
そもそもMonacoinってなに?
コメントを残す