我正在使用“主题”框架来创建一个儿童主题.它有一些钩子,但我特别看着thematic_header(). thematic_header()钩子添加以下操作(通过add_action):
<?PHP add_action('thematic_header','thematic_brandingopen',1); add_action('thematic_header','thematic_blogtitle',3); add_action('thematic_header','thematic_blogdescription',5); add_action('thematic_header','thematic_brandingclose',7); add_action('thematic_header','thematic_access',9); ?>
动作的内容是无关紧要的.
我的问题是:如何改变有关的五项行动的优先事项.例如,我希望在topicatic_brandingopen()之前加载thematic_access().只有这样做,我已经能够弄清楚是通过删除和重新添加动作,ala:
<?PHP function remove_thematic_actions() { remove_action('thematic_header','thematic_access'); add_action('thematic_header',0); //puts it above thematic_brandingopen } add_action ('init','remove_thematic_actions');
这似乎是一个愚蠢的方式来完成一件非常简单的事情.有没有办法访问和排序/重新排序WP中的任何数据结构存储操作?
从
WordPress
if a hook was registered using a priority other than the default of
10,then you must also specify the priority in the call to
remove_action().
所以我想你可以先删除使用以下
remove_action('thematic_header',1); remove_action('thematic_header',9);
并再次使用不同的优先级
add_action('thematic_header',1); add_action('thematic_header',2);