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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:49:28+00:00 2026-05-20T13:49:28+00:00

<ul class=artist-links> <?php if(!empty($artist_website)) { ?><li class=artist-website><a href=<?=$artist_website?> target=_blank><img src=<?php bloginfo(‘template_url’) ?>/images/artist-website.png alt=<?php the_title();

  • 0
<ul class="artist-links">
    <?php if(!empty($artist_website)) { ?><li class="artist-website"><a href="<?=$artist_website?>" target="_blank"><img src="<?php bloginfo('template_url') ?>/images/artist-website.png" alt="<?php the_title(); ?> Website" /></a></li><?php } ?>
    <?php if(!empty($artist_youtube)) { ?><li class="artist-youtube"><a href="http://youtube.com/<?=$artist_youtube?>" target="_blank"><img src="<?php bloginfo('template_url') ?>/images/artist-youtube.png" alt="<?php the_title(); ?> Youtube" /></a></li><?php } ?>
    <?php if(!empty($artist_twitter)) { ?><li class="artist-twitter"><a href="http://twitter.com/<?=$artist_twitter?>" target="_blank"><img src="<?php bloginfo('template_url') ?>/images/artist-twitter.png" alt="<?php the_title(); ?> Twitter" /></a></li><?php } ?>
</ul>

I want to make this unordered list show up only if at least one of the variables (artist-website, artist-youtube, artist-twitter) isn’t empty. So if all of the variables are empty, then this list won’t show up at all. What can I add before this code to make this work?

  • 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-05-20T13:49:29+00:00Added an answer on May 20, 2026 at 1:49 pm

    Just check at the beginning if they are all empty:

    Code

    <?php if(!(empty($artist_website) && empty($artist_youtube) && empty($artist_twitter))) : ?>
    
    <ul class="artist-links">
        <?php if(!empty($artist_website)) { ?><li class="artist-website"><a href="<?=$artist_website?>" target="_blank"><img src="<?php bloginfo('template_url') ?>/images/artist-website.png" alt="<?php the_title(); ?> Website" /></a></li><?php } ?>
        <?php if(!empty($artist_youtube)) { ?><li class="artist-youtube"><a href="http://youtube.com/<?=$artist_youtube?>" target="_blank"><img src="<?php bloginfo('template_url') ?>/images/artist-youtube.png" alt="<?php the_title(); ?> Youtube" /></a></li><?php } ?>
        <?php if(!empty($artist_twitter)) { ?><li class="artist-twitter"><a href="http://twitter.com/<?=$artist_twitter?>" target="_blank"><img src="<?php bloginfo('template_url') ?>/images/artist-twitter.png" alt="<?php the_title(); ?> Twitter" /></a></li><?php } ?>
    </ul>
    
    <?php endif; ?>
    

    Explanation

    Basically we check each variable for the condition “empty”. If all 3 are empty, the result of AND(true,true,true) is true. Then we see the “!” or the NOT operator, which reverses that true and makes it a false. So if all the variables are empty, then do no print the lines in between.

    You may also notice the “:” / “endif” syntax i’ve used, which I find much neater when splicing into tags of html.

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

Sidebar

Related Questions

<?php for ($i=0; $i< count($resultz[musicshara][link]); $i++) { { echo'<div class=track><a href='.$resultz[musicshara][link][$i][slink].' class=control download title=\u0421\u043a\u0430\u0447\u0430\u0442\u044c
I have a simple model like this one: class Artist(models.Model): surname = models.CharField(max_length=200) name
I have a base class Participants inherited by Artist, Author and TextWriter. I have
I have a class Song with properties Title, Key, Artist, etc. There are no
In Django, I have an app with models like this: class Artist(models.Model): name =
I have the following models class Track include Mongoid::Document field :artist, type: String field
I have following models class Artist(models.Model): name = models.CharField(max_length=200, unique=True) photo = models.CharField(max_length=250) views
I am trying to Deserialize an XML file into a few class objects: Artist,
well it's quiet simple. 2 models with ManyToMany relation: class Artist(models.Model): name = models.CharField(max_length=100,
I have the following model: class Artist(models.Model): cell_phone = models.CharField(20) pr_phone = modelsCharField(20) In

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.