Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Resolved] Add Filter to Theme's functions.php

Home Forums Support Add Filter to Theme's functions.php

  • This topic has 3 replies, 2 voices, and was last updated 6 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #42629
    Dominik Günder

    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

    #42696
    Tom
    Lead Developer
    Lead Developer

    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;'));

    #42783
    Dominik Günder

    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. 😉

    #43591
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.