Home Forums Theme Support Dokan Correct code in functions.php for style.css

This topic is: not resolved

This topic contains 4 replies, has 3 voices, and was last updated by  Marita 5 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #19259

    Post count: 58

    I've seen this mentioned in another thread, but can you please update line 269 in the functions.php file.

    Change from:
    wp_enqueue_style( 'style', $template_directory . '/style.css', false, null );

    Change to:
    wp_enqueue_style( 'dokan-stylesheet', get_stylesheet_uri(), array(), '1.0.3', 'all');

    This makes it easy to create a child theme, which will have a style.css to override the style.css in the parent dokan theme.

    All that has to be at the top of the child theme's style.css is:

    Theme Name: Dokan Child Theme
    Theme URI: http://wedevs.com/dokan
    Description: This is a child theme for Dokan
    Author: We Devs
    Author URI: http: //www.wedevs.com/
    Template: dokan
    Version: 1.0.3
    @import url("../dokan/style.css");

    Then only the version number needs to be updated in the parent style.css, the child style.css, and the functions file when updating Dokan.


    Tareq Hasan
    Post count: 2831

    Hello Simon,

    Thanks for the post. Although we are not using style.css for Dokan instead /assets/css/style.css. One thing can be done is on Dokan theme is to register the stylesheet first and then enqueue it. Then if you don't need the styles in the child theme, you can dequeue the stylesheet from the child theme.


    Post count: 58

    Hi Tareq,

    Technically you are using the main style.css as it's required by WordPress. Just because you've decided to add additional stylesheets does not mean that style.css is not enqueued — as can be seen on line 269 of your functions.php.

    Please see this page: https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

    As a workaround, I've already dequeued line 269 in my child theme's function.php file, but there is no need for this if you could make the simple fix. This will make it easier for you, and others, to create their child theme.

    Here's what I'm currently doing in the functions.php in my child-theme.

    /* Remove default stylesheet */ 
    add_action('wp_enqueue_scripts', 'bwf_remove_scripts');
    function bwf_remove_scripts(){
        wp_dequeue_style( 'style' );
    /* Add replacement stylesheet */
    add_action('wp_enqueue_scripts', 'bwf_add_scripts');
    function bwf_add_scripts(){
        /* main style */
        wp_enqueue_style( 'dokan-stylesheet', get_stylesheet_uri(), array(), '1.0.3', 'all'); 

    Post count: 58

    Additional details on how child themes work. https://codex.wordpress.org/Child_Themes


    Post count: 7

    Simon i agree that changing the functions.php to make child theme support standard can easily be done – but i find this just as easy to create a functions.php in my child theme and add this code.

    All that its doing is loading the style.css from my child theme as the last style in the wp_enqueue_scripts function.

    function theme_name_scripts() {
        wp_enqueue_style( 'yellow-ribon', get_stylesheet_uri() );
    add_action( 'wp_enqueue_scripts', 'theme_name_scripts', 99 );
Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Correct code in functions.php for style.css’ is closed to new replies.