小编eld*_*dov的帖子

如何在Wordpress中更改操作优先级?

我正在使用Thematic框架作为儿童主题.它有许多钩子,但我特别关注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);
?>
Run Code Online (Sandbox Code Playgroud)

行动的内容无关紧要.

我的问题是:如何改变有关五项行动的优先顺序.例如,我想在thematic_brandingopen()之前加载thematic_access().我能够弄清楚的唯一方法就是删除并重新添加动作,ala:

<?php
  function remove_thematic_actions() {
    remove_action('thematic_header', 'thematic_access');
    add_action('thematic_header', 'thematic_access', 0); //puts it above thematic_brandingopen
  } 
  add_action ('init', 'remove_thematic_actions');
Run Code Online (Sandbox Code Playgroud)

这似乎是一种完成非常简单的事情的愚蠢方式.有没有办法访问和排序/重新排序任何存储WP中的操作的数据结构?

php wordpress

15
推荐指数
2
解决办法
1万
查看次数

标签 统计

php ×1

wordpress ×1