Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:49:28+00:00 2026-06-09T04:49:28+00:00

I am trying to load images through custom fields, rather than using the featured

  • 0

I am trying to load images through custom fields, rather than using the featured image.

My custom fields are as follows

name:  image-small
value: /images/thumbs/small/example.jpg

PHP

<img src='<?php echo get_post_meta($post->ID, 'image-small', true); ?>'>

yet instead of writing the img src as

http://localhost/project.co.uk/images/thumbs/small/example.jpg

it displays

http://localhost/images/thumbs/small/example.jpg

is there a way to either write the htaccess so that it re-routes the url or, do I have to hardcode it into the HTML until I go live, then replace the code with whats above? Or is there a much easier way to do it?

I have found

  • relative paths to image file in wordpress (3.3.1) custom fields?

but it didn’t help me resolve it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:49:30+00:00Added an answer on June 9, 2026 at 4:49 am

    Your problem is that the URL in that field begins with a “/”, which means “go back to the root of the domain”. Since as far as your browser is concerned the domain is “localhost”, you get the “http://localhost/images/…” resolution.

    Note that it’s your browser doing this interpretation, not the PHP code.

    What you need to do is echo at the beginning of the src=”” attribute the base that you want to put on the URL, so that you’re outputting the full URL from “http://” onwards. Looking at your example, this will probably be home_url() or site_url()

    That is, your code will become something like: <img src='<?php echo home_url() . get_post_meta($post->ID, 'image-small', true); ?>'>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load about 600 small images into memory. Size of each image
I am trying to load images through ajax call in jquery using This here
I'm trying to load an image through PHP, but I don't know how. The
I'm trying to load some images using Bitmap.getBitmapResource() , but it takes about 2
Javascript newbie here, trying to load Twitter profile images using the URLs returned by
As the title says im trying to load Facebook profile images into flash using
I'm using KML to load an image overlay, and then I'm trying to change
I am trying to load in all of the images within a folder using
I'm using the HtmlAgilityPack and trying to extract an image name from html. Here's
i'm trying to load images from Facebook Albums to my flex app, this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.