最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Widget display nothing

programmeradmin2浏览0评论

I have 6 widgets in Wordpress. Three works correct, but three display nothing. Code of one which is not working is:

register_sidebar(array(
        'name' => __('Title Footer Menu Third'),
        'id'   => 'sidebar-title-c',
        'before_widget' => '',
        'after_widget'  => '',
        'before_title'  => '',
        'after_title'   => ''
    ));

I try to display this into footer.php just like that:

<p style="font-size: 12px;margin-top:-4px;font-weight: 900;color: #fff;border-bottom: solid 1px #02B4EA;padding-bottom: 5px;"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("sidebar-title-c") ) :  ?>
<?php endif;?></p>

Why is not working for all six widgets?

I have 6 widgets in Wordpress. Three works correct, but three display nothing. Code of one which is not working is:

register_sidebar(array(
        'name' => __('Title Footer Menu Third'),
        'id'   => 'sidebar-title-c',
        'before_widget' => '',
        'after_widget'  => '',
        'before_title'  => '',
        'after_title'   => ''
    ));

I try to display this into footer.php just like that:

<p style="font-size: 12px;margin-top:-4px;font-weight: 900;color: #fff;border-bottom: solid 1px #02B4EA;padding-bottom: 5px;"><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("sidebar-title-c") ) :  ?>
<?php endif;?></p>

Why is not working for all six widgets?

Share Improve this question asked Mar 19, 2020 at 14:34 MariuszMariusz 212 bronze badges 2
  • do you see all six corresponding widget areas in the dashboard under 'Appearance' - 'Widgets'? and did you add at least one widget into each of the areas? – Michael Commented Mar 19, 2020 at 14:48
  • 1 When you say widget, do you mean a widget in a sidebar, or do you mean a sidebar itself? It looks like you've muddled up sidebars and widgets, or at least I think you have, it makes the question confusing – Tom J Nowell Commented Mar 19, 2020 at 15:09
Add a comment  | 

1 Answer 1

Reset to default 0

Your if statement is empty. Also I don't think your if statement is correct. Can you try this:

<?php if ( is_active_sidebar( 'sidebar-title-c' ) ) : ?>
    <p style="font-size: 12px;margin-top:-4px;font-weight: 900;color: #fff;border-bottom: solid 1px #02B4EA;padding-bottom: 5px;">
        <?php dynamic_sidebar( 'sidebar-title-c' ); ?>
    </p>
<?php endif; ?>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论