I have a plugin template that I need to overwrite but I need to be able to put the updated file in my theme to avoid changes getting overwritten by updates.

The file is located at '/wp-content/plugins/newspack-blocks/src/blocks/homepage-articles/templates/article.php' I have tried putting the same path in my theme but that doesn't seem to work not sure if there is a proper way of doing this or maybe some sort of function that can tell Wordpress which file to use?

  • There's no system in WordPress that allows child themes to replace arbitrary plugin files. It's up to the plugin to provide a way for you to do that. So the answer to this will be specific to that plugin. You will need to ask its author or consult its developer documentation for assistance. Dec 9, 2021 at 14:53
  • you could do something similar to what plugins do and filter locate_template to add this as a fallback for when the file isn't in the theme but how you would do that i'm not 100% on the particulars. You would need to explicitly code in support, as Jacob said there's no generic PHP file replacement mechanism you can use. WooCommerce does something like this
    – Tom J Nowell
    Dec 9, 2021 at 15:07


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.