【WordPress】bodyに任意のクラス名を付ける
記事更新日:2022-09-13
![サムネイル](https://tsukiusagi.biz/wp-content/uploads/2022/01/wordpress.png)
header.phpに記述
![](https://i0.wp.com/tsukiusagi.biz/wp-content/uploads/2022/01/rabbit3.png?resize=150%2C150&ssl=1)
body_class()の中にクラス名を記述
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="(ファビコンのパス)" type="image/svg+xml">
<?php wp_head(); ?>
</head>
<body <?php
if (is_single() || is_page()) {
body_class('(任意のクラス名)');
} else {
body_class();
}
?>>
2022-09-13
編集後記:
この記事の内容がベストではないかもしれません。
記事一覧
-
パンくずリストを作る 【WordPress】パンくずリストを自作する -
カスタム投稿を複数作成する 【WordPress】カスタム投稿を複数作成し、カスタムタクソノミーも追加する -
function_existsで関数を作る 【WordPress】if (!function_exists()が必要な理由|子テーマでカスタマイズしやすくなる -
絵文字を停止する 【WordPress】高速化|絵文字を読み込む設定を停止する -
シンプルなページネーション 【WordPress】ページネーションを作る関数|the posts pagination -
RichTextでブロックエディタを作ってみる 【ブロックエディタ】RichTextのシンプルな使い方|文字入力できるBox作成