问题描述
由于某些原因,我的孩子主题模板未被识别。
我相信我已经按照正确的程序操作(并检查了缓存等)
/wp-content/themes/divi-child/includes/builder/module/Blog.PHP
应替换
/wp-content/themes/Divi/includes/builder/module/Blog.PHP
(相同路径和相同文件,但稍有更新)
任何建议都非常感谢。
欢呼
编辑
以下根据Divi应该可以使用,但是当我尝试操作时会中断网站。
显然,仅将模块复制到子主题中是不够的。该文件需要复制。然后将文件复制到child-theme / custom-modules / Blog.PHP。将以下代码添加到functions.PHP文件的底部之后:
function divi_custom_blog_module() {
get_template_part( '/custom-modules/Blog' );
$myblog = new custom_ET_Builder_Module_Blog();
remove_shortcode( 'et_pb_blog' );
add_shortcode( 'et_pb_blog',array( $myblog,'_render' ) );
}
add_action( 'et_builder_ready','divi_custom_blog_module' );
解决方法
还有一些其他步骤https://intercom.help/elegantthemes/en/articles/4532734-moving-blog-module-in-child-theme
-
在子主题文件夹中新建一个文件夹,例如includes文件夹。
-
现在将 Divi/includes/builder/module/Blog.php 文件从父主题复制到 child-theme/includes/ 文件夹中。
-
打开您的子主题的 Blog.php 文件并替换这一行(在最顶部):
require_once 'helpers/Overlay.php';
class ET_Builder_Module_Blog extends ET_Builder_Module_Type_PostBased {
与:
get_template_part( '/includes/builder/module/helpers/Overlay.php' );
class custom_ET_Builder_Module_Blog extends ET_Builder_Module_Type_PostBased {
替换:$this->vb_support = 'on'; $this->vb_support = 'off';
从底部删除这一行:new ET_Builder_Module_Blog();
- 最后,将以下代码添加到子主题文件夹中的 functions.php 文件中:
/*================================================
#Load custom Blog Module
================================================*/
function divi_custom_blog_module() {
get_template_part( '/includes/Blog' );
$myblog = new custom_ET_Builder_Module_Blog();
remove_shortcode( 'et_pb_blog' );
add_shortcode( 'et_pb_blog',array( $myblog,'_render' ) );
}
add_action( 'et_builder_ready','divi_custom_blog_module' );
,
我遇到了与此类似的问题。我认为-博客模板可能是由“父亲主题”文件夹中的另一个文件调用的,例如:
$url = dirname(__FILE__)."/includes/builder/module/Blog.php";
这将导致问题。要解决此问题,有两种方法:
#1:查找和编辑称为博客模板的文件(不推荐)
#2:查找并复制文件,即将博客模板称为您的子主题(您可以先尝试使用index.php,content.php或single.php)(推荐)