Modify Wordpress plugin function in functions.php

牧云@^-^@ 提交于 2019-12-06 04:13:10

Without changing the core plugin code, I don't think you can achieve what you want.

Well written plugins usually have apply_filters method called on anything that might need to be tweaked by a theme developer. As such, the plugin code should look something like this:

// Using apply_filters() to allow overriding of values...
public static function loop_shop_per_page() {
    $value = get_option( 'posts_per_page' );
    return apply_filters('filter_loop_shop_per_page', $value);
}

Then, in your functions.php file, you'd be able to change the value on for that by adding a filter like so:

add_filter('filter_loop_shop_per_page', 'mytheme_loop_shop_per_page');

function mytheme_loop_shop_per_page($value){
    return -1;
}

Unfortunately, unless you edit the plugin code you probably won't be able to do what you want. You could always search the plugin for apply_filters to see if there's anything else you might be able to tweak to achieve the same results.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!