user866339
user866339

Reputation: 439

Directory problems when using permalinks in wordpress

I am running into a problem when coding a theme. My wordpress folder lives in public_html/ The permaline setting is set to "Post name", so it is something like http://websiteurl.com/post-name/

In my theme, I want to load an image that lives in public_html/media/, but when I use

<img src="media/img.jpg">

the browser tries to find the image in the folder public_html/post-name/media/img.jpg. How should I code my theme so this does not happen? I don't want to change my permalink option to ?page=ID.

Thank you!

Upvotes: 0

Views: 86

Answers (2)

Santosh Kori
Santosh Kori

Reputation: 371

It will better to use full absolute path like

<img src="http://websiteurl.com/media/img.jpg">

. So it will not create issue when your path will http://websiteurl.com/category/post-name/

Upvotes: 1

Hobo
Hobo

Reputation: 7611

Try

<img src="/media/img.jpg">

instead. The first / will make the browser start looking under public_html instead of under post-name.

Upvotes: 0

Related Questions