Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <section>
- <?php if ( have_posts() ) while ( have_posts() ) : the_post(); //ループの開始
- <h1><?php the_title();//記事タイトルの出力?></h1>
- <time><?php the_time("Y.n.j");//投稿日時の出力。"Y年.n月.j日"等カスタマイズ可?></time>
- <?php //カテゴリ名、ターム名を取得
- $terms = get_the_terms( $post->ID, 'category' );//'category'を各タクソノミー名に変更
- if ( $terms && ! is_wp_error( $terms ) ) :
- foreach ( $terms as $term ) {//配列を回す?>
- <span><?php echo $term->name;?></span>
- <?php } endif;?>
- <?php if (has_post_thumbnail() ) {//アイキャッチ画像の有無を判別
- $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'full')//アイキャッチ画像の情報を取得;?>
- <img src="<?php echo $thumbnail[0]//アイキャッチ画像へのリンクを出力?>" alt="<?php the_title_attribute(); //altとして記事タイトルを出力?>" width="100" height="100">
- <?php } else {//アイキャッチ画像がない場合の代替画像?>
- <img src="<?php echo get_template_directory_uri(); ?>/assets/img/page/hogehoge.jpg" alt="<?php the_title_attribute(); ?>" width="760" height="475">
- <?php } ?>
- <p><?php the_content();?></p>//記事本文の出力
- <?php endwhile;//ループ終わり?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement