Wordpress: Image placed in the header.php add in the internal pages

0

No header.php I put for example

<img src="wp-content/themes/meu_tema/asserts/imagens/logo.png" title=" />

On the homepage it works, but on the inside it does not work.

How to get around this?

    
asked by anonymous 14.11.2016 / 15:51

1 answer

0

You're using a relative URL, so when you leave the homepage, wp-content/themes/meu_tema/asserts/imagens/logo.png is being added to the URL of the page you're on, so it does not work.

The quick (and dirty) way to resolve is to add / to the beginning of the URL:

<img src="/wp-content/themes/meu_tema/asserts/imagens/logo.png" title=" />

The most correct way is to use get_template_directory_uri() or get_stylesheet_directory_uri() , like this:

<img src="<?php echo esc_url( get_template_directory_uri(). '/asserts/imagens/logo.png' ); ?>" title="" />
<img src="<?php echo esc_url( get_stylesheet_directory_uri(). '/asserts/imagens/logo.png' ); ?>" title="" />
    
14.11.2016 / 18:06