I have a plugin which creates a custom post type "projects". In the plugin folder is a template file (single-project.php) where i would like to make some changes. But i'm wondering how i can override this file from the child theme i'm working on. I've tried to make a copy and place it in my child theme folder, but wordpress doesn't pick that one up. How can i achieve this without editing the file in the plugin folder (and risk lose my changes when the plugin is updated?)

  • You should ask the plugin's developers. All plugins are different. – vancoder Feb 19 at 17:51
  • 1
    @vancoder No, in that regard they are not. – fuxia Feb 19 at 18:04

Use the filter template_include to override a template path. Example:

add_filter( 'template_include', function( $template ) {
    if ( ! is_singular() ) {
        return $template;
    if ( 'project' !== get_post_type() ) {
        return $template;
    // Now we can safefely
    return get_stylesheet_directory() . '/single-project.php';      
  • Thanks a lot! That worked – Geertjan Feb 20 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.