【发布时间】:2012-09-03 18:50:48
【问题描述】:
假设我有这样的功能:
add_filter("post_gallery", "fix_my_gallery_wpse43558",10,2);
function fix_my_gallery_wpse43558($output, $attr) {
// blah, blah, blah
}
基本上,上面的函数允许我使用post_gallery 过滤器覆盖内置(AKA 默认)WordPress 图片库模板。
问题是,我只想在我的自定义提要中覆盖默认的 WordPress 图片库模板,为此我需要使用 if ( is_feed( $feeds = 'custom_feed' ) ) { .... } 条件标签。
问题是,条件标签里面的函数的正确操作方式是什么?
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
}
}
或
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
}
}
【问题讨论】: