2个已注册的动态侧边栏,未显示

时间:2013-10-06 作者:user1255049

我的目的是在每页上都有一个左右侧边栏。我已经注册了这两个小部件,实现了我想要的小部件,但有些地方不太对劲。

左侧边栏(sidebar(1)) 在左侧正确加载,但卡在页面内容下方。右侧边栏(sidebar(2)) 虽然它在外观>小部件中显示为活动状态,但根本不会显示在页面上。

我忽略了什么?如何才能使两个侧边栏正常显示和运行?谢谢

以下是我所拥有的:

仅有一个的php

<?php get_header(); ?>

<div id="content">

    <div id="blog">

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <h1 class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>

        <p class="date">Posted on <?php the_time(\'F j, Y\'); ?> | <?php comments_popup_link(\'No Comments\', \'1 Comment\', \'% Comments\'); ?></p>


        <div class="post">
            <?php the_content(__(\'Read more\'));?><div style="clear:both;"></div>

            <div class="bt-links"><strong>Category:</strong> <?php the_category(\', \') ?><br /><?php the_tags(\'<strong>Tags:</strong> \',\' > \'); ?></div>
        </div><!-- end post -->

        <!--
        <?php trackback_rdf(); ?>
        -->

        <?php endwhile; else: ?>

        <p><?php _e(\'Nothing found here, uh oh!\'); ?></p><?php endif; ?>

    </div><!-- end blog -->

</div>

<!-- The main column ends  -->

<?php get_sidebar(\'l\'); ?>
<?php get_sidebar(\'r\'); ?>
<?php get_footer(); ?>
提要栏-l.php

<div id="sidebar-left">
    <ul class="l_sidebarwidgeted">
        <?php if ( function_exists(\'dynamic_sidebar\') && dynamic_sidebar(1) ) : else : ?>
    </ul>
</div><!-- end sidebar-left -->
提要栏-r.php

<div id="sidebar-right">
    <ul class="l_sidebarwidgeted">
        <?php if ( function_exists(\'dynamic_sidebar\') && dynamic_sidebar(2) ) : else : ?>
    </ul>
</div><!-- end sidebar-right -->
功能。php

<?php
if ( function_exists(\'register_sidebars\') )
    register_sidebars(2);
?>
css

#sidebar {
    width: 200px;
}

#sidebar-left {
    float: left;
}

#sidebar-right {
    float: right;
}

p.sidebar {
    font-size: 80%;
}

2 个回复
SO网友:Michael

您对侧栏模板使用了错误的文件名;尝试文件名sidebar-l.php和sidebar-r.php

回顾http://codex.wordpress.org/Function_Reference/get_sidebar

SO网友:wpmemorize

大多数情况下,当您在函数中错误地注册侧栏时,就会出现问题。php或使用与用于输出侧栏的名称不匹配的名称注册sider。

您可以在这里添加代码,用于在函数中注册侧栏吗。php?所以我可以看看到底是什么问题。

你可以找到here 这就是如何在WordPress主题中创建多个小部件区域。

结束