Warning: Cannot modify header information - headers already sent by (output started at /home/fukuro-press/www/fukuropress/index.php:4) in /home/fukuro-press/www/fukuropress/wp-content/plugins/all-in-one-seo-pack/app/Common/Meta/Robots.php on line 87

Warning: Cannot modify header information - headers already sent by (output started at /home/fukuro-press/www/fukuropress/index.php:4) in /home/fukuro-press/www/fukuropress/wp-includes/feed-rss2-comments.php on line 8
子テーマにjavascriptファイルを追加してスクリプトを呼び出す方法 へのコメント https://fukuro-press.com/child-theme-add-javascript/ 「できない」を「デキル」に変えるWordPressブログ術 Thu, 22 Feb 2024 07:33:36 +0000 hourly 1 https://wordpress.org/?v=4.9.25 フク郎 より https://fukuro-press.com/child-theme-add-javascript/#comment-40 Fri, 10 Jul 2020 03:26:47 +0000 http://fukuro-press.com/?p=1963#comment-40 コメントありがとうございます。
はい、その手順で問題ありません、

ただしPHP編集については本当に慎重に行ってください。JavaScriptならまだしも、PHPでエラーが出たら大変です。特に古いWPバージョン(恐らく3.x未満)はエラーが出たらホワイトスクリーンなので・・・

とはいえPHPコード的には恐らく問題ないですね。それからJavaScriptコードは環境によるので、一概に「全く問題ない」とは断言できません。

]]>
ひろ より https://fukuro-press.com/child-theme-add-javascript/#comment-39 Thu, 09 Jul 2020 11:44:26 +0000 http://fukuro-press.com/?p=1963#comment-39 こんばんわ。プラグインのJSファイルのオーバーライドが上手く行かなくて調べていたところこちらのページを見つけたのですが書かれている内容は以下のような意味合いで合ってますでしょうか?

子テーマのfunction.phpに以下を追加。
function link_scripts(){
wp_enqueue_script(‘jquery’, dirname(__FILE__).’/javascript.js’, array(), false, true);
}

add_action(‘wp_enqueue_script’, ‘link_scripts’);

子テーマ直下にjavascript.jsを作り以下のようなコードを追加。
setTimeout( function() {

if ( $( “.tribe-amount:contains(‘.00’)” ) ) {

$(‘.tribe-amount’).html( $(‘.tribe-amount’).html().substring(0,$(‘.tribe-amount’).html().length – 3) );

};

}, 10);

$( document ).ready( function() {

if ( $( “.tribe-amount:contains(‘.00’)” ) ) {

$(‘.tribe-amount’).html( $(‘.tribe-amount’).html().substring(0,$(‘.tribe-amount’).html().length – 3) );

};

} );

]]>