1
위젯 항목의 특정 순서에 대한 클래스를 추가 할 수있는 방법이 있습니까? 즉 클래스 이름은 widgetorder-1 (첫 번째 나타나는 위젯의 경우), widgetorder-2 (두 번째 순서로 나타나는 위젯의 경우) 등입니다. 필터를 살펴 보았지만 어떻게 작동되는지는 확실하지 않았습니다.Wordpress 사이드 바 클래스
위젯 항목의 특정 순서에 대한 클래스를 추가 할 수있는 방법이 있습니까? 즉 클래스 이름은 widgetorder-1 (첫 번째 나타나는 위젯의 경우), widgetorder-2 (두 번째 순서로 나타나는 위젯의 경우) 등입니다. 필터를 살펴 보았지만 어떻게 작동되는지는 확실하지 않았습니다.Wordpress 사이드 바 클래스
// Set this to whatever number you'd like the ordering to start on.
$my_blog_widget_count = 0;
// put your blog sidebar here
$my_blog_sidebar_id = '';
function output_my_widget_info($a){
global $my_blog_sidebar_id, $my_blog_widget_count;
if($a[0]['id'] == $my_blog_sidebar_id){
global $my_blog_sidebar_id, $my_blog_widget_count;
$a[0]['before_widget'] = preg_replace('/ class="widget /i', ' class="widget widget-'.$my_blog_widget_count.' ', $a[0]['before_widget']);
$my_blog_widget_count++;
}
return $a;
}
add_filter('dynamic_sidebar_params','output_my_widget_info');
그게 도움이 될 것입니다. 테마의 functions.php 파일 안에 그냥 붙이면 작동하는 것을 지켜보십시오.