- This topic is empty.
November 29, 2011 at 11:17 am #35384
I have a number of jpg files within the images folder of my custom themes that are linked to a template. I can’t see what is wrong but the images are appearing broken. I can only imagine I have the file path wrong:
Similarly, I am trying to link images dynamically to the custom fields set on the relevant WP back-end page and nothing is appearing. I am using the following code in the relevant template:
I have tried to link this to to the page “images/sales.jpg” in the custom field.November 29, 2011 at 11:24 am #91500
Both will be wrong because it’s not linking to your theme’s folder.
For the first one:
For the second, make sure you are linking to the absolute path of the image. The absolute path would be something like:
http://www.yourwebsite.com/wp-content/themes/yourthemename/images/sales.jpgNovember 29, 2011 at 11:29 am #91501
@The Doc – thanks for this. For the second one, where I want to link images through custom-fields on the back-end pages, do I not have to use php code as well?
Or did you just mean the path in that page needed readjusting?November 29, 2011 at 11:43 am #91503
Yea, the path needs readjusting. You don’t need to include the domain, but everything after it.November 29, 2011 at 12:00 pm #91505
Out of interest, have you ever deleted a page and then created it again with the same title at another point to find the slug has changed to say /about-2/
Can you ever get it back to its original state?November 29, 2011 at 12:06 pm #91506
By the way, is the php code right with the second one, as the link is not working.November 29, 2011 at 12:07 pm #91507
PHP should not be used in the custom field. The PHP is for the first image that you posted.
It probably has about-2 because your deleted page is still in the trash and can be restored. Delete it permanently and you should be able to use /about/.November 29, 2011 at 12:10 pm #91508
Not in the custom field but the corresponding area in the template.November 29, 2011 at 12:13 pm #91509
It should be working. Is anything showing at all? Are you running the code within the loop?November 29, 2011 at 12:18 pm #91513
No, nothing is showing and it is within the loop.November 29, 2011 at 12:33 pm #91515
Well something must be showing up in the HTML. If you have the following:
Then the minimum that would show up in the HTML would have to be:
Is that what you see?November 29, 2011 at 12:37 pm #91516
is what is showing up in the html.November 29, 2011 at 1:08 pm #91522
Can you take a screenshot of what you see in the custom field area of your post? (the edit screen)November 29, 2011 at 1:17 pm #91524
Only the Sales box is relevant. I have also tried without the / in front of wp-content.November 29, 2011 at 1:44 pm #91530
With or without the slash should work. I don’t know why it’s not working! In case you had any spelling mistakes, try copying what I’ve put below:
If that doesn’t work, post the entire template where you are trying to use the custom field.
- The forum ‘Other’ is closed to new topics and replies.