Quantcast
Channel: Function Inside Conditional Tag - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Function Inside Conditional Tag

$
0
0

Say I have a function like this:

add_filter("post_gallery", "fix_my_gallery_wpse43558",10,2);function fix_my_gallery_wpse43558($output, $attr) {    // blah, blah, blah}

Basically, the function above allows me to override the built-in (AKA default) WordPress image gallery template using the post_gallery filter.

The thing is, I would like to override the default WordPress image gallery template ONLY IN my custom feed, for which I need to use the if ( is_feed( $feeds = 'custom_feed' ) ) { .... } conditional tag.

The question is, what is the right way to operate the function inside the conditional tag?

if ( is_feed( $feeds = 'custom_feed' ) ) {    add_filter("post_gallery", "fix_my_gallery_wpse43558",10,2);    function fix_my_gallery_wpse43558($output, $attr) {        // blah, blah, blah    }}

or

add_filter("post_gallery", "fix_my_gallery_wpse43558",10,2);function fix_my_gallery_wpse43558($output, $attr) {    if ( is_feed( $feeds = 'custom_feed' ) ) {        // blah, blah, blah    }}

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images