register_sidebar( array( 'name' => esc_html__( 'Сайдбар', 'zone-theme' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'Add widgets here.', 'zone-theme' ), 'before_widget' => '<div class="sidebar-widget">', 'after_widget' => '</div>', 'before_title' => '<div class="widget-title">', 'after_title' => '</div>', ) ); 

I do.

that's what it does.

enter image description here

In the code, I can add a wrapper for the widget title (before_title + a_t) and I can also add a wrapper for the entire widget (before_widget + a_w). How to wrap your html, ul tag (widget content). As I know there is no such type parameter before_content and after_content. Or is there?)

I need this code structure

 <div class="sidebar-widget"> <div class="widget-title">...</div> <div class="widget-content"><ul>...</ul></div> </div> 
  • The simplest solution in the after_title is to set up a div for the content '</ div> <div class = "widget-content">' and in the after_widget add another closing tag '</ div> </ div>'. - noname228

1 answer 1

For good in such cases it is much easier and more efficient to determine the appropriate layout in the widget itself.

 public function widget($args, $instance) { $title=$instance[“title”]; echo “<aside class=\”widget widget_recent_entries\”>”; echo “<h2 class=\”widget-title\”>$title</h2>”; // Это уже контент виджета echo “<p>”.Date('d').” “.Date(“M”).” “.Date(“Y”).”</p>”; echo “</aside>”; } 

The sidebar parameters are intended for setting not only the widgets themselves, but their display in it. Something like this...

  • Well, it's a crap knc. In each file of the widget will it be necessary to change it? - plaglamist
  • Well, it's WordPress ... - Streletz