0

I'm building a site into which I'm incorporating a wordpress blog and during my customisation of a theme I've run into a slight snag.

I'm using a couple of widgets in the footer to display recent posts etc but they are displaying with their own inline styling. I can't find anywhere that may be adding the styling but I have found the function in the functions.php file that adds the id and class for the elements in question and I'm wondering whether I can add some php to the function in order to remove the styling that follows:

code is as follows:

function twentythirteen_widgets_init() {
    register_sidebar( array(
        'name'          => __( 'Main Widget Area', 'twentythirteen' ),
        'id'            => 'sidebar-1',
        'description'   => __( 'Appears in the footer section of the site.', 'twentythirteen' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h3 class="widget-title">',
        'after_title'   => '</h3>',

    ) );

the on-page code is like this:

<aside id="recent-posts-2" class="widget widget_recent_entries masonry-brick" style="position: absolute; top: 0px; left: 0px;">

so i want to leave the id and class but just strip out the "style" elements

I know php may not be the best way to do this so i'm open to suggestions but if i can pop a preg replace or reg ex etc into the function that would be great.

Cheers guys

Smokescreen
  • 189
  • 3
  • 4
  • 13
  • You can always override inline styles with `!important` in your CSS, albeit on a case-by-case basis. – Blazemonger Oct 14 '13 at 18:02
  • 2
    It's likely the inline styling is added on runtime by javascript, looks like the [masonry jquery plugin](http://masonry.desandro.com/)? – Damien Pirsy Oct 14 '13 at 18:06
  • Hmm both good comments thanks, for some reason I didn't think ! Important would work as it would be parsed before the following inline style but I guess that defeats the point of ! Important. As for the JavaScript suggestion I'll check it out thanks. – Smokescreen Oct 14 '13 at 18:10
  • thanks guys, i've just altered the functions.php file to remove the masonry plugin function for the footer widgets and so far at least it seems to have done the trick! Thanks a lot for your help :) – Smokescreen Oct 14 '13 at 20:08

1 Answers1

0

I had this problem earlier and as suggested in the comments by @Damien Pirsy, the issue was that the masonry jquery plugin was enqueued in the theme's functions.php file like so:

   <?php
        // Remove the following
        if ( is_active_sidebar( 'sidebar-3' ) ) {
            wp_enqueue_script( 'jquery-masonry' );
        }
    ?>

This is a relic from the original WordPress twentyfouteen theme so make sure to test well after you remove it.

Chizzle
  • 1,707
  • 1
  • 17
  • 26