filemtime(): stat failed warning within a child theme

Question

I am trying to work on my child theme, but I can’t get rid of the filemtime(): stat failed warning, which appeared as soon as I activated my child theme.
After reading other questions, I understand that the filemtime warning is often caused by incorrect use of URLs and paths. However, I think I provided URLs and paths correctly, and if that’s the case, then there is something else I’m missing.

This function is from the parent theme:

function mtt_styles()
{
    wp_enqueue_style(
    'mtt-custom-style', 
    get_stylesheet_directory_uri() . '/dist/css/custom-style.css', 
    false, 
    filemtime(get_stylesheet_directory() . '/dist/css/custom-style.css'), 
    'all'
    );
  
    wp_enqueue_style('mtt-main-style', get_stylesheet_uri());    
}
add_action('wp_enqueue_scripts', 'mtt_styles');

This is from my child theme:

function child_styles()
{
    $theme = wp_get_theme();    
    wp_enqueue_style(
        'mtt-custom-style',
        get_template_directory_uri() . '/dist/css/custom-style.css',
        array(),
        filemtime(get_template_directory() . '/dist/css/custom-style.css'),
        'all'
    );
    wp_enqueue_style(
        'mtt-main-style',
        get_template_directory_uri() . '/style.css',
        array(),
        $theme->parent()->get('Version'),
        'all'
    );
    wp_enqueue_style(
        'child-main-style', 
        get_stylesheet_uri(), 
        array('mtt-custom-style', 'mtt-main-style'));
}
add_action('wp_enqueue_scripts', 'child_styles');

When I go to the page source, I see that the enqueueing worked. All the files are there, and all the styles from the parent theme work well within the child, but the warning remains.

Could someone help me spot what I am missing or doing wrong here?

0
Kris K 1 month 0 Answers 6 views 0

Leave an answer