简体   繁体   中英

How to call php bloginfo directory wordpress on a function

How to call PHP blog info 'wordpress code' inside my php function, on my image src.

 <?php
  $show_social = get_option('theme_show_social_menu');                                    
  $sl_faceook = get_option('theme_facebook_link');
  if($show_social == 'true')
    {
    ?>
    <ul class="social-nav">
       <div class="footer_social">    
 <?php
    echo ($sl_faceook) ? '<img src="<?php bloginfo('stylesheet_directory'); ?>/images/fold/GGGGG-03.png   " alt="facebook" /><a target="_blank" href="'.$sl_faceook.'"></a></li>' : '';                                                       
     ?>        
</div><!--//footer_social-->
 </ul>

You can try this code:

<ul class="social-nav">
    <div class="footer_social">    
        <?php if($sl_faceook):?>
            <li><a target="_blank" href="<?php echo $sl_faceook ?>"><img src="<?php echo bloginfo('stylesheet_directory'); ?>/images/fold/GGGGG-03.png" alt="facebook" /></a></li>
        <?php endif; ?>    
    </div><!--//footer_social-->
</ul>

If you are using a child theme, you should use this or if you are not using a child theme get_template_directory but, I would suggest to use a child theme.

<?php
      $show_social = get_option('theme_show_social_menu');                                    
      $sl_faceook = get_option('theme_facebook_link');
      if($show_social == 'true')
        {
        ?>
        <ul class="social-nav">
           <div class="footer_social">    
     <?php
        echo ($sl_faceook) ? '<img src="' . get_stylesheet_directory_uri() . ' /images/fold/GGGGG-03.png" alt="facebook" width="150px" height="150px" /><a target="_blank" href="'.$sl_faceook.'"></a></li>' : '';                                                       
         ?>        
    </div><!--//footer_social-->
     </ul>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM