[resolved] How Do i make a child functions.php file without getting an error (4 posts)

  1. Michael Burke
    Posted 11 months ago #

    i am try to make sure i dont lose modifications to functions.php if i get a theme update but i cant figure out what i have to do because the child one goes before the parent right?

  2. Craig Ralston
    Posted 11 months ago #

    Try following the steps outlined in the codex: https://codex.wordpress.org/Child_Themes

    Keep in mind - A style.css in your child theme is required to tell WordPress that this is in fact, a child theme.

    If you have already got that far and still are seeing issues, let me know.

  3. esmi
    Forum Moderator
    Posted 11 months ago #

    The child's function.php file always starts off empty - then you add just the new or customised functions to it.

  4. alchymyth
    Forum Moderator and Sweeper
    Posted 11 months ago #

    what i have to do because the child one goes before the parent

    consider to add the functions, which have to start after the parent theme's ones, by using the 'after_setup_theme' action.


    example - adding a new widget area to a child theme:

    add_action( 'after_setup_theme', 'twentytwelvechild_setup' );
    function twentytwelvechild_setup() {
    add_action( 'widgets_init', 'twentytwelvechild_widgets_init' );
    function twentytwelvechild_widgets_init() {
    	register_sidebar( array(
    		'name' => __( 'Custom Sidebar', 'twentytwelve' ),
    		'id' => 'sidebar-4',
    		'description' => __( 'Appears on Custom page', 'twentytwelve' ),
    		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    		'after_widget' => '</aside>',
    		'before_title' => '<h3 class="widget-title">',
    		'after_title' => '</h3>',
    	) );


You must log in to post.

About this Topic