こんにちは、しばです。 最近WordPressで、カテゴリやタグ・カスタム分類に画像のカスタムフィールドを実装したいなぁと思い、色々調べる機会がありました。 情報は落ちてるは落ちてるんですが、どれもプラグインを使った方法ばかり(´・ω・`) サイト全体でカスタムフィールドをバンバン使うならまだしも、その箇所しか使わない予定だったので、無闇にプラグインを増やしたくないなぁと思いプラグインを使わない実装方法を調べてみました。 functions.php 出力したいテンプレート この2箇所にコードを書くだけで対応できる方法をまとめたので、同じように困ってる方の参考になれば幸いです! 実装イメージ まず、どういう時にこの「カテゴリやタグ、カスタム分類に画像のカスタムフィールドを実装」が必要になるかという例をあげてみます。 アーカイブ(一覧)ページの画像(又は背景)を、タームごとに変えたいという場合