• Resolved Alexander Goncharov

    (@luzlol)


    Hi guys!

    First of all, thanks for a great theme! I just wanted to ask you to include conditional statement into theme functions.php around flounder_widgets_init() function. Otherwise I’m not able to overwrite it in my child theme.

    Thanks =)

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael

    (@alchymyth)

    the ‘flounder_widgets_init()’ is added via add_action( 'widgets_init', 'flounder_widgets_init' );

    generally, remove that action first in your child theme, and add your own ‘init’ function.

    https://codex.www.ads-software.com/Function_Reference/remove_action

    Thread Starter Alexander Goncharov

    (@luzlol)

    child theme loads before the parent theme

    one does not simply remove not added action hook =)

    ronangelo

    (@ronangelo)

    child theme loads before the parent theme
    one does not simply remove not added action hook =)

    Yes. But that doesn’t mean that functions added on the child-theme are executed first. All functions are collected first then executed depending on their priority or whenever they are called.

    You should be able to accomplish what you want by adding this on your child-theme’s functions.php, just tested and it works as expected.

    function remove_default_sidebar() {
    	remove_action( 'widgets_init', 'flounder_widgets_init' );
    }
    add_action( 'after_setup_theme', 'remove_default_sidebar' );
    
    function add_custom_sidebar() {
    	register_sidebar( array(
    		'name'          => __( 'Sidebar', 'flounder' ),
    		'id'            => 'sidebar-1',
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</aside>',
    		'before_title'  => '<h1 class="widget-title">',
    		'after_title'   => '</h1>',
    	) );
    }
    add_action( 'widgets_init', 'add_custom_sidebar' );
    Thread Starter Alexander Goncharov

    (@luzlol)

    wow, that’s sweet! worked like a charm for me =)

    thanks a lot Ron!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘flounder_widgets_init()’ is closed to new replies.