agenda widget heading style
-
Hi Stephen,
I was having some problem styling widget’s headings in my custom theme this was because I wasn’t able to target a specific widget heading if i was using multiple different widgets on the same page. The problem that i am having is as follows:
<div class="sidebar"> <h2>widget 1 heading</h2> <div class="widget1"></div> <h2>agenda widget heading</h2> <div class="eo-agenda-widget"></div> <h2>widget 3 heading</h2> <div class="widget3"></div> </div>
because of this i wasn’t able to target any specific widget’s heading to style as If I do .sidebar .h2 it styles all the heading for me where as I need different headings style for different widgets. what im actually after is
<div class="sidebar"> <div class="widget1"><h2>widget 1 heading</h2></div> <div class="eo-agenda-widget"><h2>agenda widget heading</h2></div> <div class="widget3"><h2>widget 3 heading</h2></div> </div>
The way you have implemented this puts the h2 heading comes before the actual div as follows:
function widget($args, $instance){ global $wp_locale; wp_enqueue_script( 'eo_front'); wp_enqueue_style( 'eo_front'); extract($args, EXTR_SKIP); add_action('wp_footer', array(__CLASS__, 'add_options_to_script')); $id = esc_attr($args['widget_id']).'_container'; self::$agendas[$id] = array( 'id'=>esc_attr($args['widget_id']), 'number'=>$this->number, 'mode'=> isset($instance['mode']) ? $instance['mode'] : 'day', 'add_to_google'=>$instance['add_to_google'] ); //Echo widget echo $before_widget; $widget_title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); if ( $widget_title ) echo $before_title.esc_html($widget_title).$after_title; echo "<div style='width:100%' id='{$id}' class='eo-agenda-widget'>"; ?> <div class='agenda-nav'> <span class="next button ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" title=""> <span class="ui-button-icon-primary ui-icon ui-icon-carat-1-e"></span><span class="ui-button-text"></span> </span> <span class="prev button ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" role="button" title=""> <span class="ui-button-icon-primary ui-icon ui-icon-carat-1-w"></span><span class="ui-button-text"></span> </span> </div> <?php echo "<ul class='dates'>"; echo '</ul>';//End dates echo "</div>"; echo $after_widget; } function add_options_to_script() { if(!empty(self::$agendas)) wp_localize_script( 'eo_front', 'eo_widget_agenda', self::$agendas); } }
As you can see below the title is checked and displayed before the actual widget div
if ( $widget_title ) echo $before_title.esc_html($widget_title).$after_title; echo "<div style='width:100%' id='{$id}' class='eo-agenda-widget'>";
Is there a way so that I can have h2 headings within the widget div? help will be very much appreciated.
Thanks,
Farhan
- The topic ‘agenda widget heading style’ is closed to new replies.