PHP 调用生成一个 UL。我不知道如何让三个li元素进入那个UL



我正试图将社交媒体图标与WP菜单放在页面的同一行。菜单由一个PHP调用调用,图标由另一个调用。这使得它们是独立的UL。我如何将它们放在同一UL中,以便它们出现在我的页面上的同一行?这是代码:该页面的链接是www.traultainer.net

<!-- The Navigation Menu -->
<ul id="navi">
<h1 id="fittext3"><a href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a><i><?php bloginfo('description');?></i></h1>
<ul id="fittext1" style="width: 100%;><?php if ( has_nav_menu( 'bar' ) ) :  wp_nav_menu( array( 'theme_location' => 'bar', 'depth' => 2 ) ); else : ?>
<?php wp_list_pages( 'title_li=&depth=2' ); ?>
    <?php endif; ?>
<?php if ( ( get_theme_mod('facebook_setting') != 'The url link goes in here.' ) && ( get_theme_mod('facebook_setting') != '' ) ) : ?><li><a href="<?php echo get_theme_mod('facebook_setting') ;?>" class="icon-facebook-rect"></a></li><?php endif; ?>
<?php if ( ( get_theme_mod('twitter_setting') != 'The url link goes in here.' ) && ( get_theme_mod('twitter_setting') != '' ) ) : ?><li><a href="<?php echo get_theme_mod('twitter_setting') ;?>" class="icon-twitter"></a></li><?php endif; ?>
<?php if ( ( get_theme_mod('youtube_setting') != 'The url link goes in here.' ) && ( get_theme_mod('youtube_setting') != '' ) ) : ?><li><a href="<?php echo     get_theme_mod('youtube_setting') ;?>" class="icon-youtube"></a></li><?php endif; ?>
<?php endif; ?>
<!-- End Navigation Menu -->

未测试,快速且肮脏,但我认为这应该是你想要的:

<?
function settingExists($name)
{
    return ((get_theme_mod($name) != 'The url link goes in here') && get_theme_mod($name) != ''));
}
if(settingExists('facebook_setting') || settingExists('twitter_setting') || settingExists('youtube_setting'))
{
    echo("<li>");
    if(settingExists('facebook_setting')){
        echo("<a href="get_theme_mod('facebook_setting')>" class="icon-facebook-rect"></a><)";
    }
    if(settingExists('twitter_setting')){
        echo("<a href="get_theme_mod('twitter_setting')>" class="icon-facebook-rect"></a><)";
    }
    if(settingExists('youtube_setting')){
        echo("<a href="get_theme_mod('youtube_setting')>" class="icon-facebook-rect"></a><)";
    }
    echo("</li>");
}
?>

最新更新