Site logo

Archived topic

Relative or full path URLs?

1 reply · Started by Rui on December 13, 2019

Viewing posts 1–2 of 2

Hello!

Inside a code snippet or a hook, what is the best practice: use relative or full path URLs?

When calling an image, for example, it would be better to use:

img src=”./wp-content/uploads/fig.jpg”

img src=”https://mydomain.com/wp-content/uploads/fig.jpg”

or even ‘img src=’ . $_SERVER['DOCUMENT_ROOT'] . ‘/wp-content/uploads/fig.jpg’ ?

Hi there,

I always just use the full URL as it always works.

Not sure if there is a best practice though as long as they work.

The theme itself doesn't control this at all.

This archived topic is closed to new replies.