Site logo

Archived topic

Making Child Theme functions.php work

3 replies · Started by Reinoud on March 15, 2021

Viewing posts 1–4 of 4

As Dashicons seem to slow down my site speed I wanted them gone. I have found this code that I should add to functions.php:

function wpdocs_dequeue_dashicon() {        if (current_user_can( 'update_core' )) {
            return;
        }
        wp_deregister_style('dashicons');
}
add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' );

this does the trick, but I read it is better to do this within a Child theme. I have never done this before but I found a page where you explain and where I can download a blank one. Which I did, and I put the code in the child theme's functions.php which looks like this now:

<?php
/**
 * GeneratePress child theme functions and definitions.
 *
 * Add your custom PHP in this file.
 * Only edit this file if you have direct access to it on your server (to fix errors if they happen).
 */
function wpdocs_dequeue_dashicon() {        if (current_user_can( 'update_core' )) {
            return;
        }
        wp_deregister_style('dashicons');
}
add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' );

This is not deleting the Dashicons problem. Should I do something else? Does the Child theme automatically overrule the Main theme? Because it does not seem to do that. Maybe I forget one step? Thx

Hi there,

first thing to check - is the Child Theme active ?

Hi David,

Thank you.
No it wasn't. It is now and it works. I understand better what it does now :)

Awesome - glad to hear that :)

This archived topic is closed to new replies.