dongsi5381 2018-10-22 06:34
浏览 160

如何在wordpress中添加/更改页脚作为插件功能?

I've created a custom widget area in the plugin I'm creating.

function arphabet_widgets_init() {

register_sidebar( array(
    'name'          => 'Home right sidebar',
    'id'            => 'home_right_1',
    'before_widget' => '<div>',
    'after_widget'  => '</div>',
    'before_title'  => '<h2 class="rounded">',
    'after_title'   => '</h2>',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );

dynamic_sidebar( 'home_right_1' );

And to enable showing the widgets stored in this widget I have inserted this code inside the footer.php of the theme I'm currently using for testing.

<?php if ( is_active_sidebar( 'home_right_1' ) ) : ?>
                <div id="primary-sidebar" class="primary-sidebar widget- 
 area" role="complementary">
                    <?php dynamic_sidebar( 'home_right_1' ); ?>
                </div><!-- #primary-sidebar -->
                <?php endif; ?> 

It works, when I add widgets to my widget area, they are shown in footer of the website. But I want to make the plugin works without changing the footer.php manually. How can I check which theme is activated and then find that theme, the footer.php file and add that code exacltly where I want (to be shown below any other footer created with the theme when is installed. Also, I would like to remove the footer that was generated before.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 cruise如何仿真不同温度下车辆的经济性?
    • ¥20 扑克牌游戏的完整代码
    • ¥88 求帮安装Python架构的vnpy
    • ¥20 逻辑回归法分析品牌知名度和购买意向
    • ¥15 华为云主机-异常连接
    • ¥50 vue 成绩列表 输入成绩,并统计各分数段人数
    • ¥20 请教怎么绕过这个卡密系统 大家交流一下
    • ¥15 设计数字电路得到要求结果
    • ¥15 hfss 组天线阵列报错:The A and B vectors must be parallel to the XY plane,如何解决?
    • ¥30 ansible连接设备报错