Archived topic
Add Filter to Theme's functions.php
3 replies · Started by Dominik Günder on October 29, 2014
Hey there,
today i've got two questions if you don't mind.
I want to add the following to the themes functions.php:
add_filter('wp_feed_cache_transient_lifetime',create_function('$a', 'return 60;'))
This will force RSS Widgets to refresh every 60 seconds so i always have got the latest information from my forums.
1.) When you release a theme update, all my custom information from functions.php are gone. Is there a clean way to prevent this?
2.) After the latest theme update my string does not work anymore. I added it - as usual - to "forefront"'s functions.php but then my page won't load. (Just shows a white page)
Do you have any ideas about this?
Thanks in advance,
Dominik
Hi Dominik,
1. Yes - this is annoying, and the trouble with releasing child themes. Your best bet is to use this plugin: https://wordpress.org/plugins/pluginception/
It allows you to create a plugin that you can add your PHP to - this way, theme updates won't ever touch your custom functions.
2. Make sure it looks like this:
add_filter('wp_feed_cache_transient_lifetime',create_function('$a', 'return 60;'));
Hey Tom,
thanks for the quick answer. Pluginception works perfectly. I'm wondering how you always find these awesome plugins.. I've been searching for this over the last days. ;)
Glad I could help! :)