私はWordpressの構造とjavascript/phpを学んでいるので、誰かがこの問題を解決するのを手伝ってくれることを願っています.
私がやろうとしているのは、header.php に配置した div を表示することですが、ロードされるのは「index.php」ファイルの場合のみです。
このように見えるべきではありませんか?
$(document).ready(){
    if.this(document == "http://sample.com/") {
        this.document.getElementById('only-show-when-index').style.display = "visible";
    } else {
        this.document.getElementById('only-show-when-index').style.display = "hidden";
    }
};