• Hello,
    I would like to know if it’s possible to add some widgets in the header zone (under the main menu) like the little flags for other languages, and a search bar.
    I have set up a child theme for this, .
    Does the theme allow to do so ?
    Thanks for your help

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Ziabelle, you can add new widget areas in any theme, if you’re comfortable with making some edits in your child theme. Here are some guides to adding new widgetized areas to a theme:

    https://codex.www.ads-software.com/Widgetizing_Themes
    https://www.dummies.com/how-to/content/how-to-register-new-widget-areas-to-your-wordpress.html

    Thread Starter Ziabelle

    (@ziabelle)

    Hi Kathryn
    thanks for your quick answer.
    I followed the instructions in the provided links. But doing so, it breaks my site when I work on the functions.php file.
    As I created a child theme, I have understood that I need to create another functions.php and not change the parent theme file.

    So I created a new functions.php file with this code inside :
    <?php
    register_sidebar( array (
    ‘name’ => __( ’header_widget’),
    ‘id’ => ‘header_widget’,
    ‘description’ => __( ‘Widget in the header’),
    ‘before_widget’ => ‘<li id=”%1$s” class=”widget-container %2$s”>’,
    ‘after_widget’ => “”,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’,
    ) );
    ?>

    but when I go back to my administration panel, the page is white, it’s breaking the whole thing.
    I’m probably making a very obvious mistake, but I ‘m new with this editing changes.

    The reason that happened is that the widget function in Sketch is not “pluggable” – it’s not wrapped in a ! function_exists check – so it can’t just be copied into the child theme’s functions file.

    Only “pluggable” functions that are wrapped in a conditional tag to check whether the same function already exists elsewhere can be overriden in the child theme by just re-declaring them.

    Because of this, it becomes more complicated to override the widget setup in your child theme. You’ll need to add a new function to remove the default widget setup function in Sketch, and then add a new function called something else to create your new widget setup.

    You can learn more about pluggable functions here:

    https://code.tutsplus.com/articles/understanding-wordpress-pluggable-functions-and-their-usage–wp-30189

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add widgets in the header’ is closed to new replies.