将侧边栏生成器插件包含在我的 WP 主题中



我正在尝试包含此插件:

http://wordpress.org/extend/plugins/sidebar-generator/

进入我的WordPress主题。正如互联网上的许多人所说,我只是将sidebar_generator.php文件包含在我的函数中.php。"侧边栏"菜单出现在外观下,但无论我做什么,如果我单击它,则没有任何反应(就像它在"#"上链接一样)。

如果我通过wordpress界面安装插件,一切正常,我需要集成它。

有什么帮助吗?

谢谢

你不需要插件来拥有额外的侧边栏。您应该能够构建具有任意数量的侧边栏的主题模板。当我在WordPress中创建自定义主题时,我使用了960 CSS Grid的变体(另一个不错的是较新的1140px CSS Grid System,它是流动的)。

要注册侧边栏以接受小部件,请将以下代码插入函数.php文件中:

// Widget Areas //
if ( function_exists('register_sidebars') ) {
    // Primary sidebar widget
    register_sidebar( array(
        'name' => __( 'Blog Sidebar', 'unique' ),
    'id' => 'blog-sidebar',
    'description' => __( 'The sidebar widget area for the blog.', 'unique' ),
    'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class="widget-title">',
    'after_title' => '</h2>',
) );
register_sidebar( array(
    'name' => __( 'Left Sidebar', 'unique' ),
    'id' => 'left-sidebar',
    'description' => __( 'The left sidebar widget area for pages.', 'unique' ),
    'before_widget' => '<li id="%1$s" class="greenGradient widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class="widget-title greenbar center">',
    'after_title' => '</h2>',
) );
register_sidebar( array(
    'name' => __( 'Right Sidebar', 'unique' ),
    'id' => 'right-sidebar',
    'description' => __( 'The right sidebar widget area for pages.', 'unique' ),
    'before_widget' => '<li id="%1$s" class="redGradient widget-container %2$s">',
    'after_widget' => '</li>',
    'before_title' => '<h2 class="widget-title redbar center">',
    'after_title' => '</h2>',
) );

}在这种情况下,我有一个注册的侧边栏,只用于博客,然后一个右侧边栏和一个左侧边栏。

在我的主题目录中,我有三个侧边栏.php文件。博客侧边栏文件是默认的侧边栏.php文件。另外两个分别命名为侧边栏左.php和侧边栏右.php。每个侧边栏都有相应的代码,如下所示:

   <?php // blog widget area
        if ( is_active_sidebar( 'blog-sidebar' ) ) : ?>
        <ul>
            <?php dynamic_sidebar( 'blog-sidebar' ); ?>
        </ul>
    <?php endif; // end blog widget area ?>

将此代码包装在侧边栏中的div 中,并确保将"博客侧边栏"名称更改为每个侧边栏的名称。

查找函数admin_menu并在该行中进行编辑。只需将__FILE__替换为sidebar-generator即可。

解释:如果您使用侧边栏生成器作为插件,__FILE__意味着 sidebar-generator ,但如果您将其包含在主题的某个目录中,常量__FILE__可能会更改为不同的东西(例如 inc,包括...或其他东西)

最新更新