[デモ会員サイト構築]18. その他のsimplicityのカスタマイズ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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>'; | |
// | |
// 略 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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>'; | |
// | |
// 略 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; ?> | |
// | |
// 略 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 一行目はシンタックスハイライトするために追加しています。 | |
// カスタム投稿タイプとアイコン | |
$my_post_icon = array( | |
"travel" => "fa-camera", | |
"cake" => "fa-birthday-cake", | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment