2017-03-24 20 views
0

私は自分のウェブサイトでGenesis Frameworkを使用しています。ウェブサイトのナビゲーションメニューとプライマリサイドバーにカスタムCSSクラスを追加したいと思っていました。Function.phpで複数のフィルタを追加するには?

add_filter('genesis_attr_nav-primary', 'themeprefix_add_css_attr'); 
function themeprefix_add_css_attr($attributes) { 

$attributes['class'] .= ' toggle'; 

return $attributes; 

} 

とナビゲーションプライマリに追加された「トグル」という名前の新しいクラス:

はこれを実現するために、私は次のコードを使用していました。

しかし、私は次のようにプライマリサイドバーに新しいCSSクラスを追加するためのFunction.phpにコードを追加すると、私のウェブサイトは、あなたが同じ2つの関数を定義しているように、エラー500

add_filter('genesis_attr_sidebar-primary', 'themeprefix_add_css_attr'); 
function themeprefix_add_css_attr($attributes) { 

$attributes['class'] .= 'toggle2'; 

return $attributes; 

} 

答えて

0

が見える示しました。名前は、エラーの原因となります。以下試してください:各フィルタは、異なる機能を参照している

add_filter('genesis_attr_nav-primary', 'themeprefix_add_nav_css'); 
function themeprefix_add_nav_css($attributes) { 

$attributes['class'] .= ' toggle'; 

return $attributes; 

} 


add_filter('genesis_attr_sidebar-primary', 'themeprefix_add_sidebar_css'); 
function themeprefix_add_sidebar_css($attributes) { 

$attributes['class'] .= 'toggle2'; 

return $attributes; 

} 

注:themeprefix_add_nav_cssthemeprefix_add_sidebar_cssを。

+0

ダビデの助けをありがとう。それは完全に働いた:) –

関連する問題