【发布时间】:2016-09-28 10:44:34
【问题描述】:
各位程序员,
我对 Wordpress 比较陌生,因为我通常使用 Typo3,所以我对 WP 中的自定义侧边栏有疑问。
我的functions.php中有以下代码
function custom_sidebars()
{
register_sidebars(4, array
(
'name' => __('Panel Startseite %d', 'me'),
'id' => 'panel-home-%d',
'description' => 'Widget Position for home panel',
'class' => 'panel-sidebar',
'before_widget' => '<div class="widget-panel-%d">',
'after_widget' => '</div>',
'before_title' => '<h2 class="panel-title">',
'after_title' => '</h2>'
));
$args2 = array
(
'name' => __('Short Bio Sidebar', 'me'),
'id' => 'shortbio-id',
'description' => 'Widget Position for short bio',
'class' => 'shortbio-sidebar',
'before_widget' => '<div class="widget-bio">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
);
register_sidebars(1, $args2);
}
add_action('widgets_init', 'custom_sidebars');
我想在我的主页上添加 4 个信息面板,并在页脚中添加另一个小字段供作者添加或更改简历。
这是我的 index.php 中的代码
<div id="main">
<div class="wrapper">
<div class="col-sm-6">
<div class="inner">
<?php dynamic_sidebar('panel-home-1'); ?>
</div>
</div>
<div class="col-sm-6">
<div class="inner">
<?php dynamic_sidebar('panel-home-2'); ?>
</div>
... and so on
同样的实现在footer.php中的给定位置。
我的问题是:
- 我通过后端菜单主题添加的内容 -> 小部件不显示,并且在我下次打开后端时被删除。
- wp-content/debug.log 中没有错误,我在激活 wp-config.php 中的选项后修复了所有常见的错误
我该如何解决这个问题,我的基本思维错误是什么?
最好的问候斯凯洛
【问题讨论】:
标签: php wordpress wordpress-theming