10

So hopefully a simple question. I have a child theme installed and have been able to successfully override changes to a .php file that is held in my theme files by uploading it to my child theme.

If I want to copy and tweak a plugin file (wp-content/plugins/plugin_name/templates/store.php).

Do I just copy and tweak this file then upload it to my child theme?

I'm assuming a child theme doesn't apply to plugin files? If not, is the best way just to download the current file, make the tweaks then override the initial file with the new one in the plugin category?

Thanks!enter image description here

3
  • 1
    Hi. It depends on how the plugin is using the template. If it's simply using include(), I don't believe this can be done.
    – Jack Johansson
    Jul 31 '17 at 4:23
  • thanks for the info - I'll reach out to the plugin developer. Jul 31 '17 at 21:47
  • I've added the picture to the original question. Looks like maybe the width of the text box overlaps with the logo, forcing it to a new line. Ideally, they'd be next to each other, or the search box would left align if below. This is really getting out of my abilities lol. Again, much appreciate you. Aug 3 '17 at 0:25
0

The plugin must use wc_get_template() to load the template store.php. You can simply copy this file in your themes/YOURTHEME-child/woocommerce/. Your child template should be loaded.

1
  • 1
    Not necessarily true :(
    – DropHit
    Nov 10 '18 at 16:18
0

create plugin folder in your child theme and overtire file in it. your_child-theme/plugin-folder/templates/filename.php

0

A child theme is no longer necessary for modifications if you use any of the below plugins, which will help you organize your work much better than a child theme.

Codesnippets works perfectly for this purpose. There is a free version. Pro version due to be released.

WPCodeBox does the same job but it is much more sleek and intuitive. They have a generous lifetime launch offer currently.

3
  • Your Codesnippets link is broken
    – Rup
    Dec 11 '21 at 0:50
  • And it doesn't look like WPCodeBox lets you override page templates?
    – Rup
    Dec 11 '21 at 0:52
  • @Rup I added the correct link now, thanks. I haven't ever used a child theme myself as when I needed it I came upon these plugins that solved my problem. Both plugins have active communities on Facebook if you want to ask them something. Codesnippets is free to try out.
    – Barnabas
    Dec 11 '21 at 21:50
0

Yes use the procedure outlined in your question. A child theme’s version of any file will override that file with the same name and path from the parent theme, aka:

parent_theme/fileA.php is overridden by whatever is in the child theme at the same path location aka child_theme/fileA.php or parent_theme/dir/file3.php will be overridden by child_theme/dir/file3.php. As long as the relative paths match and the names match. Good luck!

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.