我使用的是创世纪子主题和“创世纪合著者+”,它支持Co-Authors Plus
除了博客之外,我想在任何地方禁用作者框。
创世纪-作者加移除默认的创世纪genesis_do_author_box_single,并用gcap_author_box取代它。
到目前为止,我有一个条件函数可以从定制的post类型的gcap_author_box中删除local-bite
我用一个简单的echo测试了条件语句,它运行得很好。那么,以下几点有什么问题呢?
// Remove 'Genesis Co-Authors Plus' from custom post type
add_action('init', 'lf_remove_author_box');
function lf_remove_author_box() {
if ( is_singular( 'local-bite' ) ): {
remove_action( 'genesis_after_entry', 'gcap_author_box', 8 );
}
endif;
}有一个非常类似的帖子这里是有帮助的。
但是我不明白我需要在add_action之后马上放什么--我已经复制了创世记合著者加里面的东西,也就是init。我也试过wp,有人能帮忙吗?
发布于 2014-09-22 07:20:27
最后,我使用了“template_redirect”并将remove_action号从8改为1 :)
// Remove 'Genesis Co-Authors Plus' author box and 'filed under' from custom post type
add_action('template_redirect', 'lf_custom_cpt_display');
function lf_custom_cpt_display() {
if ( is_singular( 'local-bite' ) ): {
remove_action( 'genesis_after_entry', 'gcap_author_box', 1 );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
}
endif;
}https://wordpress.stackexchange.com/questions/162168
复制相似问题