functions - some profile informations like youtube link doesnt seem

youtube icon which is represented in code with "fa fa-youtube" doesnt seem but i have youtube link on my profi

youtube icon which is represented in code with "fa fa-youtube" doesnt seem but i have youtube link on my profile settings.

 <?php  $youtube_profile = get_the_author_meta( 'youtube_profile' );
            if ( $youtube_profile && $youtube_profile != '' ) {
                echo '<span class="fa fa-youtube"><a href="'.esc_url($youtube_profile).'"  ></a></span> ';
            }?>

youtube icon which is represented in code with "fa fa-youtube" doesnt seem but i have youtube link on my profile settings.

 <?php  $youtube_profile = get_the_author_meta( 'youtube_profile' );
            if ( $youtube_profile && $youtube_profile != '' ) {
                echo '<span class="fa fa-youtube"><a href="'.esc_url($youtube_profile).'"  ></a></span> ';
            }?>
Share Improve this question asked Jul 17, 2019 at 15:58 ahmet kayaahmet kaya 52 bronze badges 4
  • depends on wich fontawesome version you have. Try with "fab fa-youtube". – Gregory Commented Jul 17, 2019 at 16:55
  • gregory24 no, when i remove "if ...", it seem.but i need all code with now form – ahmet kaya Commented Jul 17, 2019 at 16:58
  • does link show ? you just said, icon don't show ! – Gregory Commented Jul 19, 2019 at 14:30
  • i found the source of error.it is about functions... – ahmet kaya Commented Jul 19, 2019 at 18:43
Add a comment  | 

1 Answer 1

Reset to default 0

Your reply to gregory24 isn't really explicit enough I'm afraid..

The reason you can display a FontAwesome icon without the if statement is only because this html <span class="fa fa-youtube">...</span> is loaded into the DOM of you page meanwhile your $youtube_profile variable is likely containing some value but your statement is wrong.

this should work if $youtube_profile isn't empty:

<?php  
$youtube_profile = get_the_author_meta( 'youtube_profile' );

if ( !empty($youtube_profile) || $youtube_profile != '' ) {
    echo '<span class="fa fa-youtube"><a href="'.esc_url($youtube_profile).'"></a</span> ';
}
?>

BUT.. you don't need to check twice for the same thing: !empty($youtube_profile) AND $youtube_profile != '' checks are the same

the most simple way would be to simply check it like this, no need of checking if not FALSE just check if TRUE

if ( $youtube_profile ) { ... }

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745314603a4622157.html

相关推荐

  • functions - some profile informations like youtube link doesnt seem

    youtube icon which is represented in code with "fa fa-youtube" doesnt seem but i have youtube link on my profi

    8小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信