I need to change the value of a function from a WordPress plugin that I’m using.
If I do it in the original plugin file, it works perfectly, but I’d rather make it in file functions.php to avoid problems on plugin update.
I need to change this:
public static function loop_shop_per_page() {
return get_option( 'posts_per_page' );
}
Into this:
public static function loop_shop_per_page() {
return '-1';
}
How would I go to create a filter in file functions.php to do just that?
Without changing the core plugin code, I don’t think you can achieve what you want.
Well written plugins usually have the
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:Then, in your functions.php file, you’d be able to change the value on for that by adding a filter like so:
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.