Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Child theme functions.php

Discussion in 'Misc WordPress Requests' started by robmcp, Nov 25, 2017.

  1. robmcp


    Child theme functions.php, by robmcp

    I’ve asked this before and thought that I had a handle on it, now, in light of a Core update I am not so sure.

    Updating to 4.9 I saw this message

    Heads up!
    You appear to be making direct edits to your theme in the WordPress dashboard. We recommend that you don’t! Editing your theme directly could break your site and your changes may be lost in future updates. If you need to tweak more than your theme’s CSS, you might want to try making a child theme.

    I WAS editing the chiold theme at the time.

    I had assumed that using the functions.php code below would be the correct way to do this, however I am uncertain as to the correct syntax.

    Should the functions.pgp file below work with my site, regardless

    • of the nave of tha parent theme name, and that of the child theme’s name?

    This line $parent_style = ‘parent-style’; should it say ‘parent-style’

    as a variable OR should it be the NAME of the Parent style
    e.g. $parent_style = ‘divi’;

    Likewise the child theme line says this

    wp_enqueue_style( ‘child-style’,

    Should that say wp_enqueue_style( ‘divi-child’,

    Functions.php file content example from WordPress, used as shown.
    function my_theme_enqueue_styles() {

    $parent_style = ‘parent-style’;

    wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
    wp_enqueue_style( ‘child-style’,
    get_stylesheet_directory_uri() . ‘/style.css’,
    array( $parent_style ),
    add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );

    The confusion arises as a result of the error message and the fact I am not 100% certain that the functions.php above should be used AS IS.

    Child theme functions.php

Share This Page

Monarch Social Sharing Plugin