我有一个非常好的主题。我为将来的保护创造了一个儿童主题。我想重写parent-theme/framework/shortcodes/widgets.php文件中的一个函数,该函数定义为:
function wt_shortcode_recent_posts($atts) {
//some code here
}
add_shortcode('wt_recent_posts', 'wt_shortcode_recent_posts');现在,在子主题的functions.php中,我试图重写函数如下:
function wt_shortcode_recent_posts($atts) {
//some modified code here
}我还尝试将一个文件放到与child-theme/framework/shortcodes/widgets.php.相同的目录中。也不起作用。
在wordpress子主题中重写这些函数或php文件的正确方法是什么?
发布于 2016-02-20 18:58:47
您必须重写短代码函数。将折叠添加到您的子主题functions.php
function some_new_shortcoe_function($atts) {
// New shortcode code here
}
remove_shortcode('wt_recent_posts');
add_shortcode('wt_recent_posts', 'some_new_shortcode_function');https://stackoverflow.com/questions/35525392
复制相似问题