• Resolved uwekeim

    (@uwekeim)


    Trying to use the My Custom Functions to define a filter.

    I’ve tested successfully that the filter is actually called.

    
    add_filter('og_image_init', 'my_og_image_init');
    function my_og_image_init($images)
    {
        if ( is_front_page() || is_home() ) {
            $images[] = 'https://www.example.org/myimage.jpg';
        }
        return $images;
    }
    

    Still, even after clearing my PHP and browser cache, I see no change in the image on the resulting page.

    My question:

    Is it possible that setting filters is only supported if I really do modify the “functions.php” file, or do I have a chance to use filters through the “My Custom Functions” plug-in, too?

    • This topic was modified 4 years, 9 months ago by uwekeim.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Marcin Pietrzak

    (@iworks)

    Hi @uwekeim

    I put your code into wp-content/mu-plugins/og-custom-image.php and all works fine.

    I do not know plugin My Custom Functions and I’m not sure when it call custom functions.

    If this plugin called “too late” then it will be no fired in the proper moment.

    Marcin

    Thread Starter uwekeim

    (@uwekeim)

    Thanks, Marcin, I’ve just tried this mu-plugins and ensured that it is called.

    Again, I do not see a changed “og:image” meta tag value on my resulting page.

    I get a feeling that I’m completely misunderstanding the concept of what the filters seem to do.

    Will try to read your documentation again now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Possible to use filters with “My Custom Functions”?’ is closed to new replies.