Change widgets-functions.php file

I have a child theme based on Social.

I'd like to add widgets and change style of current widgets.

I've made changes to the file widgets-functions.php in the main theme and it works.

However, when I revert to original and put the file in the child theme, changes are not captured.

Where should I make the changes?

Thank you.
Giovanni

  • Giovanni

    Well, I'm adding functions in the widget section, not necessarily hooking them.

    And I wanted to change the function wp_add_widget_style_head.

    I wanted to add this:

    ul#recent-postcatlam li img {
    margin: 0px 10px 0px 0px!important;
    border: 1px solid #ddd;
    padding: 3px;
    float:left;
    max-width: 80px;
    width: auto;
    height:auto;
    background: #fff;
    }

    To the following function

    function wp_add_widget_style_head() {
    print "<style type='text/css' media='screen'>"; ?>
    ul#recent-postcat li img {
    margin: 0px 10px 0px 0px!important;
    border: 1px solid #ddd;
    padding: 3px;
    float:left;
    max-width: 80px;
    width: auto;
    height:auto;
    background: #fff;
    }
    #recent-postcat li div.feat-title {
    font-size: 1em; padding-bottom: 0px; margin: 6px 0px 0px 0px;
    }
    #recent-postcat li small {
    font-size: 0.85em;
    }
    ul#flickr-widget li img {
    float: left;
    margin: 0px 7px 8px 0px;
    background-color: #fff;
    border: 1px solid #eee;
    padding: 5px;
    }
    <?php print "</style>";
    }
    add_action('wp_head','wp_add_widget_style_head');

  • Jack Kitterhing

    Hi there @Giovanni

    I hope you are well today, I've been discussing this with one of our lead developers and currently you can't overwrite theme-options.php or widget-functions.php in a child theme or without keeping the changes after an update unfortunately.

    For the styles with functions.php though you can do this

    function my_custom_widget_style_head () {
    ?>
    <style>/* Whatever other style you need added. */</style>
    <?php
    }
    
    function replace_widget_styles () {
    remove_action('wp_head','wp_add_widget_style_head');
    add_action('wp_head','my_custom_widget_style_head');
    }
    add_action('init', 'replace_widget_styles');
    in your functions.php
    this will do 2 things:
    1) deactivate the theme's wp_add_widget_style_head() call injection
    2) replace it with this own variation, named my_custom_widget_style_head()
    so, basically, with this in place, the wp_add_widget_style_head() will never be called, and the my_custom_widget_style_head() will be called instead

    For other CSS, you could also use the !important code within CSS.

    Thanks!

    Kind Regards
    Jack.

  • Jack Kitterhing

    Hi there @Giovanni

    I hope you are well today.

    $tn_buddysocial_font_headline_size = $tn_buddysocial_font_size + 5;
    
    instead of
    
    $tn_buddysocial_font_headline_size = $tn_buddysocial_font_size + 2;

    This depends really on how big you want the H1 tags, you could also increase the size of h1 tags in the CSS of the child theme with a !important at the end of the h1 css.

    Thanks!

    Kind Regards
    Jack.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.