wordpress中子主题的网址 [英] url of child theme in wordpress

查看:23
本文介绍了wordpress中子主题的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 wordpress 中创建一个网站,为此我选择一个主题并创建一个子主题.

I want to create a website in wordpress, for this I take a theme and create a child theme.

我在孩子的文件夹中复制了一个style.css和header.php,因为我也想修改header.我修改了孩子的文件.

I copy in the folder of the child a style.css and header.php, because I want to modify the header too. I modify the file of the child.

在我的 style.css 中,我添加了一行 Template: with the name of the parent theme

In my style.css I add the line Template: with the name of the father theme

/*
Theme Name: Example
Theme URI: http://www.woothemes.com/
Version: 1.2.15
Description: Designed by <a href="http://www.woothemes.com">WooThemes</a>.
Author: WooThemes
Author URI: http://www.woothemes.com
Tags: woothemes
Template: mystile

  Copyright: (c) 2009-2011 WooThemes.
  License: GNU General Public License v2.0
  License URI: http://www.gnu.org/licenses/gpl-2.0.html

*/

我在 header.php 中使用这一行

I am using this line in the header.php

<?php $logo = esc_url( get_template_directory_uri() . 'images/logo.png' ); ?> 

我的孩子主题拍摄图像,但这一行返回了父亲主题的网址,没有他的孩子!

of my child theme to take a images but this line return the url of the father theme no his child!

我接受这个.

http://localhost/.../wp-content/themes/mystile/images/...

我想要这个

http://localhost/.../wp-content/themes/example/images...

任何想法

推荐答案

您需要 get_stylesheet_directory_uri,该函数首先检查子主题目录,然后检查父主题目录.您正在使用的那个只检查父目录.

You need get_stylesheet_directory_uri, this function checks first in the child theme directory and then in the parent's. The one you're using only checks in the parent directory.

底线:如果某个函数的行为不符合您的预期,请查看 Codex.很可能你会在那里找到原因.

Bottom line: if a function doesn't behave as you expect, check the Codex. Much probably you'll find out why over there.

这篇关于wordpress中子主题的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆