我最近已经深入到主题编辑通过儿童主题(我知道。所以去年夏天是对的,但黄油比从来没有的晚)。由于我是一个经过尝试和错误的“程序员”,所以我不知道我大部分时间在做什么。
有人能告诉我如何通过子主题来编辑这种设置吗?
第一层: get_template_part(模板-部件/内容);
第二层: do_action( 'hestia_blog_post_template_part','default‘);
第三层:类-hestia-blog-post-layout.php,它是真实存在的
谢谢各位
发布于 2019-11-23 15:57:17
您可以重写模板,方法是从主主题中获取模板文件,然后将其放在子主题中的相同位置。因此,假设模板名为class-hestia-blog-post-layout.php (从mainthemefolder/templates/class-hestia-blog-post-layout.php ),然后将其复制到childthemefolder/templates/class-hestia-blog-post-layout.php中。
更新
看起来您的主题(Hestia)没有使用默认的方式使用模板。孩子的主题应该如何运作,这绝对不是你做错了什么。我将template-parts/content.php添加到子程序中,并更改了
hestia_blog_post_template_part
至
hestia_blog_post_template_part2
,在子主题的class-hestia-blog-post-layout.php中,我更改了这一行。
add_action( 'hestia_blog_post_template_part', array( $this, 'render' ), 2 );
到这个
add_action( 'hestia_blog_post_template_part2', array( $this, 'render' ), 2 );
但结果还是没起作用。然后,我注意到class-hestia-blog-post-layout.php中的类是在hestia/inc/core/class-hestia-autoloader中加载的,在其中我进行了更改
'Hestia_Blog_Post_Layout' => HESTIA_PHP_INCLUDE . 'views/blog',
至
'Hestia_Blog_Post_Layout2' => HESTIA_PHP_INCLUDE . '../../hestia-child/inc/views/blog',
但它还是不起作用..。
现在我放弃了抱歉。
https://stackoverflow.com/questions/59009170
复制相似问题