0
我想修改在插件中調用的函數的參數。 插件Wordpress替換插件中的函數的參數
orplugin_load_template('templatefile.php', array(
'post_type' => $post_type,
'userdata' => wp_get_current_user(),
'dashboard_query' => $dashboard_query,
'post_type_obj' => $post_type_obj,
'post' => $post,
'pagenum' => $pagenum
));
內的原代碼我試用的版本,我放在functions.php的在我的子主題
function my_orplugin_load_template('mytemplatefile.php', array(
'post_type' => $post_type,
'userdata' => wp_get_current_user(),
'dashboard_query' => $dashboard_query,
'post_type_obj' => $post_type_obj,
'post' => $post,
'pagenum' => $pagenum
));
的add_filter( 'orplugin_load_template', 'my_orplugin_load_template',10);
我創建了我自己的templatefile.php,名爲mytemplatefile.php。我不知道將該文件存儲在插件外的位置。以及如何調用它來替換原來的插件。我想加載mytemplatefile.php來代替templatefile.php。如何實現這一目標?
看來你試圖使用一個名爲'orplugin_load_template'的過濾器而不知道'orplugin_load_template'過濾器的工作方式,恐怕不可能回答這個問題。我懷疑你使用的插件沒有過濾器,你可能誤解了'add_filter'的作用。它不會過濾現有的功能。就目前而言,在這段代碼示例中,函數my_orplugin_load_template沒有任何作用。 –
好點。你給了我正確的方向。我發現WP有一個標準的插件功能: <?php load_template($ _template_file,$ require_once)?> – user5526048