2017-01-13 7 views
0

自分のスタイルをすべてのページに貼り付ける簡単なプラグインを作りたいと思っています。 これは私のコードです:私のWordPressのプラグインがうまくいかない理由

<?php 
/* 
Plugin Name: Super Plugin 
*/ 

function mr_scripts() { 
    wp_register_style('forms', plugins_url('forms.css', __FILE__)); 
    wp_enqueue_style('forms', plugins_url('', __FILE__)); 
    echo '/* style-echo */ <style> 
     .social-icons{display:none!important;} 

     </style>'; 
} 
add_action('wp_enqueue_scripts', 'mr_scripts', 99); 

?> 

プラグインが有効になります。残念ながら私は私のウェブサイトの変更を見ていない。この問題を解決するのを手伝ってください。

答えて

0

あなたのプラグインは、多くの間違いで書かれています。何が欲しいのは、おそらく以下の通りです:スタイルのレジスタ/エンキューの正しい使用上の

<?php 
/* 
Plugin Name: Super Plugin 
*/ 

function mr_scripts() { 
    wp_register_style('forms', plugins_url('forms.css', __FILE__)); 
    wp_enqueue_style('forms'); 
} 
add_action('wp_enqueue_scripts', 'mr_scripts', 99); 


function my_head_style() { 
    echo '/* style-echo */ <style> 
     .social-icons{display:none!important;} 

     </style>'; 
} 

add_action('wp_head','my_head_style'); 

?> 

詳細情報:

https://developer.wordpress.org/reference/functions/wp_enqueue_style/ https://codex.wordpress.org/Function_Reference/wp_register_style

+0

非常に有用だったこと、ありがとうございました! – milosz

関連する問題