0

在我的网站上,该函数get_template_directory_uri()在使用我的子主题时开始返回完全错误的值。就在刚才,这一切都在工作,儿童主题和一切。然后突然间它开始回归http://example.com/~villageofmanteno/vmanteno-child,它应该是http://example.com/~villageofmanteno/yootheme-child。现在整个站点都损坏了,所有脚本 URL 都返回 404。站点根目录位于/~villageofmanteno.

这是现在真正奇怪的部分,我得到的 URL 的最后一段vmanteno-child似乎不是来自任何地方。我从来没有在任何地方输入过,没有文件或主题以vmanteno. 这个词vmanteno从来没有出现在我的代码中。所以我不知道那可能是从哪里来的。

我什至尝试删除我的子主题,重新创建它,然后复制我的旧文件,但它仍然损坏。当我关闭子主题时,一切都很好。

子主题文件夹称为yootheme-child.

现在我的子主题中唯一的模板文件是page-meetings.php,但是这个问题会影响每个页面上的整个站点,所以这与它没有任何关系。

这是我的style.css

/*
Theme Name: YOOtheme Child
Theme URI: https://yootheme.com
Template: yootheme
Author: YOOtheme
Author URI: https://yootheme.com
Description: A powerful, flexible and elegant website builder that allows you to create complex pages within minutes and customize every aspect of the theme.
Version: 1.21.6.1569423942
Updated: 2019-09-25 15:05:42
*/

我的functions.php

<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;

// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:

if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
    function chld_thm_cfg_locale_css( $uri ){
        if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
            $uri = get_template_directory_uri() . '/rtl.css';
        return $uri;
    }
endif;
add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );

// END ENQUEUE PARENT ACTION

另外我应该提一下,WordPress 地址和站点地址都设置为正确的值http://example.com/~villageofmanteno

编辑:get_template_directory_uri()get_stylesheet_directory_uri()返回相同的东西。

4

2 回答 2

2

请注意,这get_template_directory_uri()将返回父主题的 URL,如果您想要来自子主题的 URL,那么您应该使用get_stylesheet_directory_uri().

请注意,这两个函数都具有允许更改 URL 的内部过滤器,例如get_template_directory_uri()有一个名为 的过滤器template_directory_uri,因此第 3 方主题或插件可能已更改它。

于 2019-09-26T15:49:32.263 回答
0

我已经放弃解决这个问题。删除旧的子主题并创建一个具有相同名称的新主题会导致相同的问题,但是创建一个具有不同名称的新子主题以某种方式起作用。将主题名称改回 yotheme-child 会再次破坏它。不知道为什么。

于 2019-09-26T16:33:46.723 回答