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 9205133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:52:50+00:00 2026-06-17T23:52:50+00:00

Hopefully this is simple to solve. I have a few elements which pull in

  • 0

Hopefully this is simple to solve. I have a few elements which pull in form data previously entered into the database, which are added to the post as custom fields. I extract this using a php query as such:

<a href="<?php echo get_post_meta($post->ID, 'societywebsite', true); ?>" target="_blank" >Website</a> 

Obviously, this appears in the Loop (content.php) and will get added to any appropriate post. Sometimes, however, there won’t be any data because a user chose not to enter a website into the ‘societywebsite’ field on a form. When this happens, there’s no need for a link to ‘Website’ to be there, because it wouldn’t go anywhere useful.

What I’d like to know is how to have an If clause that checks if the data exists and then shows the link only if it does. I don’t mind javascript, but the cleaner and less ‘hacky’ the solution, the better, as content.php will run multiple times for search results.

Thanks so much for any help or advice you can provide.

  • 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-17T23:52:52+00:00Added an answer on June 17, 2026 at 11:52 pm

    Another way to do this, more according to the WordPress Codex is the following…

    $societywebsite = get_post_meta($post->ID, 'societywebsite', true);
    
    if ($societywebsite != '') {
        echo '<a href="' . $societywebsite . '" target="_blank" >Website</a>';
    }
    

    You can add an ‘else’ at the end of this for debugging purposes.

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

Sidebar

Related Questions

Hopefully this is simple: I have a relatively long list where each list item
New to MVC, so hopefully this will be pretty simple. I have an HTML
hopefully a pretty simple question this time. I have a Select method in a
This will hopefully be a simple one: I have a div I want to
This is hopefully a simple question: I have an OpenGL texture and would like
Hopefully this is simple enough. I need to be able to add elements to
Hopefully this is a simple problem to fix I have installed the Ruby installer
Hopefully I'm just missing something and this is simple... I have a page that
hopefully this is a simple question. I have a simple custom forum on my
I have just started looking at javascript so hopefully this will be something simple.

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.