【发布时间】:2020-03-05 18:46:53
【问题描述】:
我需要listings_recently.php 文件的子副本来对其进行更改。我需要将此文件包含到我的子主题中:/themes/listingeasy/core/widgets/listings_recently.php
据我所知,我需要告诉主题去寻找那个文件。那是在我孩子的主题functions.php 中制作的,对吗?
这是我的functions.php:
get_template_part('get_stylesheet_directory() . "/core/widgets/listings"', 'recently');
get_template_part('get_stylesheet_directory() . "/core/widgets/listings_recently.php"');
这两行都不工作。
我需要如何继续?这是文件夹架构:
themes
listingeasy
single.php
core
widgets
listing_recently.php
listingeasy-child
functions.php
single.php (I made changes here and its working)
core
widgets
listing_recently.php (Changes here aren't working)
【问题讨论】:
-
您打算在其他地方使用此代码吗?通常你不会使用这个函数向functions.php添加东西,你会使用require()。 get_template_part 在将代码片段应用到多个其他页面模板时,或者在多个地方使用时更频繁地使用,因此您不必每次都重写代码。我对您要完成的工作感到有些困惑。
-
这个文件在哪里? /themes/listingeasy/core/widgets/listings_recently.php 是在子主题还是父主题或其他主题?
-
@Sagar Bahadur Tamang,我已经用文件夹架构编辑了这个问题,以防万一。
-
@Dubvader 我已经使用文件夹架构编辑了问题,以防万一。我想对我的主题进行更改。我需要修改的文件是
listings_recently.php,但没有考虑更改。 -
@Flowen 我认为这会有所帮助:stackoverflow.com/questions/40961370/…
标签: wordpress templates wordpress-theming themes parent-child