TIPS
あるURLの時だけ一部のHTMLを表示する
<?php
if ( $_SERVER["REQUEST_URI"] == '/' ):
?>
<section class="header">
ヘッダー
</section>
<?php
endif;
?>
WordpressでJavaScriptを読み込む
パターンは何個かあるけど、wp_enqueue_scriptsで読み込むパターン。functions.phpに書いた。
テーマ直下/functions.php
//テーマディレクトリまでのパスの定数
define("DIRE", get_template_directory_uri());
function add_files(){
// wp_enqueue_style('my_style',DIRE.'/style.css');
wp_enqueue_script('common_script', DIRE.'/assets/js/common.js');
}
add_action('wp_enqueue_scripts', 'add_files');
参考↓
WordPressでファイルを読み込むためのwp_enqueue_styleとwp_enqueue_scriptの使い方と引数の意味を理解しておこう
エラー処理
Call to undefined function wp()
wp-config.phpの設定ミスか、パーミッションの問題。