Child theme doesn't read template part file

天大地大妈咪最大 提交于 2020-01-17 16:36:26

问题


I'm building my first child theme. My child theme is my active theme at the moment. So, I have a file under the parent theme which is at wp-content/themes/mytheme/template-parts/ajax-mytick-list.php and I copied it to wp-content/themes/mytheme-child/template-parts/ajax-mytick-list.php and edit it there. But the site is not showing the one that I edited under child theme. Cos if I edit the same file in parent theme, the result is reflected.

What am I doing wrong?


回答1:


You can override page templates this way, but not other files. In this case, you'll need to override the according function (guide) or hook into it with an action hook or filter.

More details according to your question below: You'll need to find out where the template-parts file is getting included. Search the parent theme for something like

require get_template_directory() . '/template-parts/ajax-mytick-list.php';

If that call is in a template file, copy it to your child theme and change the call to

require get_stylesheet_directory() . '/template-parts/ajax-mytick-list.php';

If it's not in a page template, you'll need to dig deeper, but as every theme is different, it's impossible to say how exactly you'll get there.



来源:https://stackoverflow.com/questions/57495702/child-theme-doesnt-read-template-part-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!