PHP调用生成UL。我不知道如何将三个li元素纳入UL

时间:2013-11-17 00:15:18

标签: php html-lists

我正在尝试将社交媒体图标放在与WP菜单相同的页面行上。该菜单由一个PHP调用调用,图标由另一个调用。这使得它们是独立的UL。如何在同一个UL中获取它们,使它们出现在我页面的同一行?这是代码:该页面的链接是www.trailtrainer.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 -->

1 个答案:

答案 0 :(得分:0)

未经测试,快速和肮脏,但我应该在你正在寻找的球场:

<?
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>");

}
?>