【发布时间】:2017-02-13 10:46:12
【问题描述】:
我遇到了 Remove_filter() 的问题。删除过滤器有效但不是 100%,它不会从 Read More 中删除前 3 个点,它不会替换父摘录。
更清楚我想要做的是删除 Read More 并将其更改为 [...] 。
我希望通过子主题完成此操作。
父主题functions.php代码
function new_excerpt_more($more) {
global $post;
return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More! »' . '</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
儿童主题functions.php代码。
function child_theme_setup() {
// override parent theme's 'more' text for excerpts
remove_filter( 'excerpt_more', 'new_excerpt_more' );
}
add_action( 'after_setup_theme', 'child_theme_setup' );
// Replaces the excerpt "Read More" text by a link
function new_excerpt($more) {
global $post;
return '<a class="moretag" href="'. get_permalink($post->ID) . '">[...] </a>';
}
add_filter('excerpt', 'new_excerpt');
【问题讨论】:
-
明确说明你的问题..
-
@HappyCoding,我编辑了它