4

I am working on a wordpress website and I am using _tk starter theme which is based on "Underscores" and Bootstrap.
I was styling the widget area from scratch, so I gave margin and padding = 0 to override bootstrap styles.
The problem is this worked for every widget except "Recent Comments" widget!
I checked it with developer tools and found that for recent comments widget ul and li, and inline style was forcing it to display some padding.
So I tried to search where this code is injected but failed to understand it. The ul id="recentcomments" and li class="recentcomments" reside in default-widgets.php
There is no style attribute assigned to these tags in that file. I tried searching in whole wordpress folder with folder search feature in netbeans but it does not show anywhere.
Here is the link to the screenshot. http://tinypic.com/r/efhwyt/8

Siguza
  • 21,155
  • 6
  • 52
  • 89
Vivek Padhye
  • 731
  • 3
  • 13
  • 26
  • I got the answer and it is specific to tk theme only. Its Javascript -- . It was in bootstrap.wp.js file on line 26! $( '.widget_recent_comments ul#recentcomments li' ).css( 'padding', '5px 15px'); – Vivek Padhye Aug 15 '14 at 16:26

3 Answers3

5

It seems that there is a filter for removing this unwanted styles "show_recent_comments_widget_style"

in functions.php of my theme:

add_filter( 'show_recent_comments_widget_style', function() { return false; });
Riaan Vermaak
  • 51
  • 1
  • 3
1

If you add the following to your style sheet should override the inline style.

.recentcomments
{
    padding: 0 !important;
}
Howli
  • 12,291
  • 19
  • 47
  • 72
  • but how can i remove it from the html? Is there any way? Where does this code get injected from? – Vivek Padhye Aug 15 '14 at 15:20
  • I want to completely remove this style attribute so that I can apply same styles to all widgets at the same time and based on different layouts want to add different styles. regards – Vivek Padhye Aug 15 '14 at 15:22
  • The actual code that adds that style is found on line ~873 of the default-widgets.php file in the wp-includes folder. – Howli Aug 15 '14 at 15:24
  • thanks for prompt reply. I have tried that line as well. I commented out everhting just to test and only kept $output .= '
  • ' /* REST COMMENTED */ still my code in html shows the style attribute. Please guide. regards
  • – Vivek Padhye Aug 15 '14 at 15:27
  • You would need to remove the `class="recentcomments"` from that `
  • `
  • – Howli Aug 15 '14 at 15:35
  • Any edits you make to default-widgets.php will be overwritten when you update Wordpress. – Mastrianni Aug 15 '14 at 15:38
  • Thanks it worked, I removed ul id="recentcomments" and it worked. But as @Mastrianni said any edits to this file will be overridden. Is there any way to remove it from functions.php. regards – Vivek Padhye Aug 15 '14 at 15:41
  • If you control it via CSS as he originally suggested, it will not be overwritten. That is probably the simplest way to go about it. Otherwise you're going to be doing it programmatically for a relatively small payoff. – Mastrianni Aug 15 '14 at 15:44
  • no problem, feel free to mark this as correct so others who have the same question as you will know how you solved it. – Howli Aug 15 '14 at 15:48
  • I got the answer and it is specific to _tk theme only. Its Javascript -_- . It was in bootstrap.wp.js file on line 26! $( '.widget_recent_comments ul#recentcomments li' ).css( 'padding', '5px 15px'); @Mastrianni – Vivek Padhye Aug 15 '14 at 16:14