Wordpress Widget Redirect Page

2019-08-05 15:47发布

I already created a wordpress widget for adding some featured from admin panel.I need to redirect to another page from this widget.But,when i am try to use header() method which shows a warning some thing like header already send by output....an do on.Is there any other method to redirect from wordpress widget?Please help me

标签: wordpress
1条回答
forever°为你锁心
2楼-- · 2019-08-05 16:12

There are several actions you could hook onto, most useful probably "init" or "widgets_init". Both are run before any output is printed, so you can redirect from those.

For a list of actions, see http://codex.wordpress.org/Plugin_API/Action_Reference

Example:

<?php add_action('widgets_init', 'my_redirect_function'); ?>
查看更多
登录 后发表回答