wordpress - 核心文件夹中带有下划线的 get_template_part()
问题描述
我需要一个文件的子副本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)
解决方案
我不知道你的主题。但是当您想编辑listings_recently.php 中的函数时,您可以尝试将这些函数复制到您的child-themes functions.php 并在那里进行编辑。大多数时候它都有效。
问候汤姆
编辑:尝试 require(); 在您的孩子主题functions.php中:
require('core/widgets/listings_recently.php');
编辑2(见评论,主题本身有自己的get_template_directory())
get_template_directory()
返回父模板目录的路径。利用
get_stylesheet_directory()
返回子主题目录的路径
推荐阅读
- linux - 用于 git 拉取多个存储库的并行化脚本
- angular - Angular Material 颜色不会使用自定义主题更改
- android - 更改 Android Shashlik 模拟器输入语言
- go - Emacs编译忽略编译命令变量
- sql-server - 如何使用 sys.dm_os_sys_info 中的 cpu_ticks 数据获取 cpu 利用率
- ruby-on-rails - 在 Rails 中查看管理员
- mysql - 不能查询超过 30 天
- java - 使用 FastParse 解析缩进
- angular - 如何防止点击Angular 4中的自定义按钮组件
- wordpress - wordpress 错误:图标仅在我登录时出现