R-style mid 2022にタグをつける
2022/8/11
現状のR-style(Wordpress)には記事にタグが表示されていない。
https://gyazo.com/e4152bcd6ebcc4796c4d0df03595a9be
これを変えたい。
使っているテーマは「FlatMagazinews」
ファイルを探す
template-parts/content-single.php
個別記事の表示はこれが担当している
記事でメタデータ(投稿日と投稿者)を表示している部分を探す
class="post-data-positioning"
<?php flatmagazinews_posted_on(); ?>という関数が中身を吐き出している模様
この関数を上書きするか
単にこの下にタグを追加するか
<?php the_tags(); ?>
【wordpress】各記事に付けられたタグを表示するテンプレートタグ「the_tags()」をカスタマイズしてみた | かわたま.net
https://gyazo.com/8b1168e308782c12b23e41d69beba807
表示はされたが、ミラクルダサい。
改行して下に表示する
「タグ:」というのはやめたい。
the_tags()のパラメータ
<?php the_tags('前', '区切り文字', '後'); ?>
<?php the_tags("tag","|",""); ?>にしてみる
<?php the_tags("<ul><li>","</li><li>","</li></ul>"); ?>にしてみる
<?php the_tags("<span>Tag:</span><ul><li>","</li><li>","</li></ul>"); ?>
<?php the_tags("<div style='display:flex;color:grey;'><span>Tag:</span><ul style='list-style: none;margin-left:3px;margin-bottom:0px;'><li class='taglistitem'>","</li><li class='taglistitem'>","</li></ul></div>"); ?>
だいたいできた。
追加のCSS
code:style.css
.taglistitem a{
color:grey;
}
.taglistitem a:hover{
color:darkblue;
}
https://gyazo.com/4ddfa1c0ac917628bd3dfd7b7f6bc9b0
→R-style mid 2022に次の記事ボタンをつける
R-style mid 2022 カスタマイズ