Override get_template_directory() in child theme?

Late answer, but in WordPress 4.7 two new functions were introduced to address this question.

get_theme_file_path() (for absolute file paths) and get_theme_file_uri() (for URLs) work just like get_template_part() in that they will automatically look in the child theme for that file first, then fallback to the parent theme.

In your example, you could rewrite it using 4.7 to look like this:

/**
* Load Custom Post types file.
*/
require get_theme_file_path( 'inc/post-types.php' );

More information here: https://make.wordpress.org/core/2016/09/09/new-functions-hooks-and-behaviour-for-theme-developers-in-wordpress-4-7/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)