I want to get to the bottom of why the child theme does not work. As I described earlier, I get several different strange errors. Among other things, the pictures are not visible in the media library so I can not add pictures to my posts. Several pages in admin also turn white when I click on the functions. I got one of my sites to work with child again. I deleted the child directory and uploaded the ColorMad original directory. Then it worked. My other web page I deleted all files and all code in the child directory except function.php. In that file, I deleted all code except the original code. Continued the same error !!!
Now I’ll find out why it does not work:
I have two test pages. One that I uploaded a brand new child directory I saved from ColorMag online and the other I still have the directory that does not work. I only have function.php and only the original code. This is how it looks:
………………………
The code that works in function.php:
/*
* Child theme functions file
*
*/
function colormag_child_enqueue_styles() {
$parent_style = ‘colormag_style’; //parent theme style handle ‘colormag_style’
//Enqueue parent and chid theme style.css
wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘colormag_child_style’,
get_stylesheet_directory_uri() . ‘/style.css’,
array( $parent_style ),
wp_get_theme()->get(‘Version’)
);
}
add_action( ‘wp_enqueue_scripts’, ‘colormag_child_enqueue_styles’ );
………………………
The code that does not work in function.php:
/*
* Child theme functions file
*
*/
function colormag_child_enqueue_styles() {
$parent_style = ‘colormag_style’; //parent theme style handle ‘colormag_style’
//Enqueue parent and chid theme style.css
wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘colormag_child_style’,
get_stylesheet_directory_uri() . ‘/style.css’,
array( $parent_style ),
wp_get_theme()->get(‘Version’)
);
}
add_action( ‘wp_enqueue_scripts’, ‘colormag_child_enqueue_styles’ );
………………………
As you can see, the codes are exactly the same and the files they are in have exactly the same name and the two different directories also have exactly the same name but one of them works but not the other?!
I changed codes in the two function.php files, but the function.php that did not work earlier also does not work after I changed codes?!
Now I create a new function.php instead of the function.php that does not work and put the latest code in it and test like this: I create a xxxx.txt file and rename it to fukition.php.
NOW IT WORKS!!!
The error is that the function.php is of the wrong format!
Now comes the big questions:
1. How can the file get the wrong format???
2. What are the different file formats on a server?
-
This reply was modified 4 years, 1 month ago by workmannen.
-
This reply was modified 4 years, 1 month ago by workmannen.
-
This reply was modified 4 years, 1 month ago by workmannen.