Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

url of child theme in wordpress

Tags:

wordpress

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

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.

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

*/

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!

I take this.

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

I I want this

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

any idea

like image 489
user852610 Avatar asked Sep 10 '13 16:09

user852610


People also ask

How do I find the URL of a WordPress child theme?

get_template_directory_uri() will always return the URI of the current parent theme. To get the child theme URI instead, you need to use get_stylesheet_directory_uri() .

How do I find my WordPress theme URL?

You need to find the one with /wp-content/themes in the URL. You may be able to find the Theme's URL or Theme Author's URL here which will lead you to the theme used by the website. Many WordPress sites use child themes to customize their websites.

How do I find the child theme folder?

In the case a child theme is being used, the absolute path to the parent theme directory will be returned. Use get_stylesheet_directory() to get the absolute path to the child theme directory. To retrieve the URI of the stylesheet directory use get_stylesheet_directory_uri() instead.


Video Answer


1 Answers

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.

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

like image 171
brasofilo Avatar answered Feb 06 '23 05:02

brasofilo