首页 PHP php – 如何在WordPress中更改动作优先级?

php – 如何在WordPress中更改动作优先级?

我正在使用“主题”框架来创建一个儿童主题.它有一些钩子,但我特别看着thematic_header(). thematic_header()钩子添加以下操作(通过add_action): ?php add_action(thematic_header, thematic_brandingopen, 1); add_action(thematic_header, them

我正在使用“主题”框架来创建一个儿童主题.它有一些钩子,但我特别看着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);

本文来自网络,不代表云浮站长网立场。转载请注明出处: https://www.0766zz.com/html/kaifa/php/20200831/8375.html
上一篇
下一篇

作者: dawei

【声明】:云浮站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

返回顶部