I am trying to override a parent theme's include file from a child theme. Here is the code:
parentTheme/functions.php
<?php
define ( "_CRYOUT_THEME_NAME", "fluida" );
define ( "_CRYOUT_THEME_VERSION", "1.2.6" );
require_once( get_template_directory() . "/admin/main.php" );
require_once( get_template_directory() . "/includes/setup.php" );
require_once( get_template_directory() . "/includes/styles.php" );
require_once( get_template_directory() . "/includes/loop.php" );
require_once( get_template_directory() . "/includes/comments.php" );
require_once( get_template_directory() . "/includes/core.php" );
require_once( get_template_directory() . "/includes/hooks.php" );
require_once( get_template_directory() . "/includes/meta.php" );
require_once( get_template_directory() . "/includes/landing-page.php" );
childTheme/functions.php
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>
And I want to override the /includes/core.php file
I have a childTheme/includes/core.php file
But when I change it, there are no changes on my site.
I have tried to add this code on my childTheme/functions.php :
require_once( get_stylesheet_directory() . "/includes/core.php");
But it renders a blank page on my site.
EDIT :
I have tryed this :
<?php
/**
* Enqueues child theme stylesheet, loading first the parent theme stylesheet.
*/
require_once( get_stylesheet_directory() . "/includes/core.php" ); // Core functions
function themify_custom_enqueue_child_theme_styles() {
wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'themify_custom_enqueue_child_theme_styles', 11 );
But I got this error :
Cannot redeclare xxx_function_name
(previously declared in /var/www/html/mywebsite/wp-content/themes/***childTheme***/includes/core.php:340)
in /var/www/html/tpevegetarisme/wp-content/themes/***parentTheme***/includes/core.php on line 340
So how can I do to prevent parent theme to redeclare a function