WordPress 基本タグ

01.基本ループ
//基本形 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 投稿の出力部分 <?php endwhile; else : ?> <p>ただいま準備中です</p> <?php endif; ?> //使用例 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_content(); ?> <?php endwhile; else : ?> <p>ただいま準備中です</p> <?php endif; ?>
02.テーマまでのパス
//基本形 <?php echo get_template_directory_uri(); ?> //使用例 <img src="<?php echo get_template_directory_uri(); ?>/images/logo.png" alt="logo"> <script src="<?php echo get_template_directory_uri(); ?>/js/common.js"></script>