インストール
初期設定画面
データーベース名
作成したデーターベース名
ユーザー名
root
パスワード
root
管理画面へ
/wp-login.php
便利プラグイン
- 入れとくと便利
- query monitor(なんのテンプレートか教えてくれる)
- admin bar position(バーを下にしてくれる)
テンプレートタグ
種類 | タグ |
---|---|
タイトル | <?php the_title(); ?> |
head | <?php wp_head(); ?> ※headの一番下 |
footer | <?php wp_footer(); ?> ※bodyの一番下 |
日付 | <?php the_time(get_option('date_format')); ?> |
抜粋 | <?php the_excerpt(); ?> |
著者名 | <?php the_author(); ?> |
リンク | <?php the_permalink(); ?> |
ファイルパス | <?php echo get_template_directory_uri(); ?> |
パーツファイル | <?php get_template_part('includes/footer') ?> |
本文 | <?php the_content(); ? |
画像(imgタグ全部) | <?php the_post_thumbnail(array(32, 32), array('alt' => 'アイキャッチ画像')); ?> |
画像 | <?php the_post_thumbnail('full', array('alt' => 'アイキャッチ画像')); ?> |
カテゴリー名表示 | <?php wp_title(''); ?> |
ホームurl | <?php echo esc_url(home_url('/')) ?> |
サイトタイトル | <?php bloginfo('name') ?> |
サイトキャッチフレーズ | <?php bloginfo('description') ?> |
カスタム投稿表示
※functions.phpの設定はこちらを参照↓
functions.phpでカスタム投稿タイプ作成
<?php $args = array('post_type' => 'news', 'posts_per_page' => 6 );$the_query = new WP_Query($args);if ($the_query->have_posts()) : ?>
ul.home__news-wrap
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
li
a(href!="<?php the_permalink(); ?>") <?php the_title(); ?>
<?php endwhile; ?>
a.btn__more(href="/news") もっと見る
<?php endif; ?>
'post_type' => 'news', 'posts_per_page' => 6
post_typeは投稿タイプ名
posts_per_pageは表示件数
カスタムタグ
<?php $tags = get_the_terms($post->ID, 'news_tag');foreach ($tags as $tag) : ?>
<span class="tag_name"><?php echo $tag->name; ?></span>
<?php endforeach; ?>
カスタムカテゴリー
<?php $terms = get_the_terms($post->ID, 'news_category');foreach ($terms as $term) : ?>
<span class="category_name">
<img src="<?php echo get_template_directory_uri(); ?>/img/<?php echo $term->name; ?>.png" alt="">
</span>
<?php endforeach; ?>
パーマリンク設定
カスタム構造
/%year%/%monthnum%/%post_id%/
お問い合わせフォームプラグイン
MV WP Form
カスタムフィールドプラグイン
Advanced Custom Fields
表示の仕方
<?php the_field('company'); ?>
<?php the_field('age'); ?>
header.php内でトップページとサブページのデザインを切り分ける
<?php if(is_front_page()){;?>
<!-- トップページ -->
<?php }else{;?>
<!-- トップページ以外 -->
<?php };?>
ページ別
is_page("company")
is_archive("news")
is_single("news")
ユーザー権限プラグイン
User-Role-Editor
まとめ
自分用ワードプレスメモ
日々更新していきます。