首页 文章

在主页中自定义我的wordpress插件

提问于
浏览
0

我正在使用这个插件http://wordpress.org/extend/plugins/simple-rss-feeds-widget/这对我来说很好 . 我正在使用WordPress 3.3.1 . 现在我希望我的插件位于主页的中心而不是侧面小部件中 . 我怎样才能做到这一点 . 我的意思是,我的插件位于小部件列表中,我可以将我的插件拖到我的模板后端的侧边栏中,它反映在右前角的前端 . 如何在页面中心的主页上获取我的插件?希望有人能帮助我 . 换句话说,如何在模板文件中调用自定义插件?谢谢哈恩

1 回答

  • 1

    您需要在functions.php文件中注册新的窗口小部件位置,然后添加代码以在相关模板文件中呈现该窗口小部件的内容 .

    举个例子 . 在functions.php中,您可以找到注册现有窗口小部件位置的代码部分(查找 if (function_exists('register_sidebar')) { )并在其下面注册一个新位置;

    register_sidebar(array(
            'name' => 'Home Widget Container',
            'id'   => 'home-widget',
            'description'   => 'These are widgets for the home position.',
            'before_widget' => '',
            'after_widget'  => '',
            'before_title'  => '<div class="home-widget-header"><h2>',
            'after_title'   => '</h2></div>'
        ));
    

    然后在您用于主页的模板文件中;

    <?php
            if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Home Widget Container')) :
                // This will include your widgets.
            endif; 
        ?>
    

相关问题