WP テンプレートタグ 一覧

// ヘッダー出力

<?php get_header(); ?>

※index.phpだけに使いた場合

header-index.phpファイルに記述し

出力時:<?php get_header('index.php'); ?>

 

//スタイルシート読み込み

<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>">

※テーマフォルダ直下のstyle.css

 

// フッター出力

<?php get_footer(); ?>

 

// ブログ・サイトのタイトル

<?php bloginfo('name') ?>

 

// ブログ・サイトの紹介文

<?php bloginfo('description') ?>

 

// ホームURL

<?php echo home_url(); ?>

<a href="<?php echo home_url(); ?>">

 

// 画像のURL

<img src="<?php echo get_template_directory_uri(); ?> /gazou-img.jpg"

alt="<?php bloginfo('description'); ?>">

※ルート階層にある画像パス

 

◯記事

 

// ワードプレスループ

<?php if(have_posts()): while(have_posts()):

the_post(); ?>

 

<?php endwhile;endif; ?>

 

// クラス指定

<?php post_class('toshi'); ?>

<article <?php post_class('toshi'); ?>>

 

//  記事タイトル

<?php the_title(); ?>

 

// コンテンツ出力

<?php the_content(); ?>

 

◯概要

// 概要

<?php excerpt(); ?>

 

// リンク

<a href="<?php the_permalink(); ?>">