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

  • SEARCH
  • Home
  • 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 8808667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:40:53+00:00 2026-06-14T02:40:53+00:00

I have a custom field (called ‘website’) where a user enters the website to

  • 0

I have a custom field (called ‘website’) where a user enters the website to their URL. My php code is as follows

<div class="profileInfo">
   <h4  class="website">Website:</h4>
      <?php if ( get_post_meta($post->ID, 'website', true)) { ?>
        <p><a href="http://<?php echo get_post_meta($post->ID, 'website', true) ?>"><?php echo get_post_meta($post->ID, 'website', true) ?></a></p>
      <?php } else { ?>
    <p class="na">no email provided</p>
    <?php } ?>
</div>

In the above example I prefix the URL with http://

So my problem is, when a user enters a url like http://www.example.com to the custom field it does not link to the site correctly. The URL looks like this on the frontend http//www.example.com

Strangely the colon : is stripped away or taken out so the URL does not work!I assume this is something to do with having two http://

Now, I have tried removing the http:// from the PHP code liek this

<p><a href="<?php echo get_post_meta($post->ID, 'website', true) ?>"><?php echo get_post_meta($post->ID, 'website', true) ?></a></p>

So let’s say the user now enters http://www.example.com to the custom field and publishes the entry. The Url now goes to

http://mysite.com/www.example.com

It tries to build the URL into my current site page. No idea why it does not treat it as a URL.

Looking for some help how to correctly write this code in PHP.

Thanks

  • 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-14T02:40:54+00:00Added an answer on June 14, 2026 at 2:40 am
    <?php 
    if ( get_post_meta($post->ID, 'website', true)) 
    {
        $link = get_post_meta($post->ID, 'website', true);
        $link = str_replace(array('http://','https://'), array('',''), $link);
        ?><p><a href="http://<?=$link?>"><?=$link?></a></p><?php 
    }  
    else
    { 
        ?><p class="na">no email provided</p><? 
    } 
    ?>    
    

    This will replace all http:// in the url.

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

Sidebar

Related Questions

I have a custom field in WordPress called thumb-url which contains the exact location
I have a custom field called HourField, which lets you enter 1:30 to represent
I have a TFS 2010 Work Item Type with a custom field called Requested
I have a User and Setting . Setting has a :serializable field called :custom_links
I have a multiple pages in wordpress all with a single custom field called
I have a phpBB installation. I've added custom profile field called 'insurance number'. Every
I have a custom content type which has a field called location which is
Details Ok. So i have a custom field on my posts called Location. This
I have a custom content type that has a custom field called [stock] I
In my website, I have a custom content type called projects. This type as

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.