-1

Wordpress サイトの RSS フィード ウィジェットから「[...]」を削除し、「...」に置き換えたいと考えています。

関数に以下を追加しようとしました:

function replace_ellipsis($text) {

$return = str_replace('[...]', '...', $text);
 return $return;
}
add_filter('get_the_excerpt', 'replace_ellipsis');

ただし、これはウィジェットには影響しません。

何か助けはありますか?

4

2 に答える 2

1

これは v3.4.2 のwp-includes/default-widgets.phpの 848 ~ 862 行で定義されていesc_htmlます。

add_filter('esc_html', 'transform_ellipsis');
function transform_ellipsis($s_html) {
    return str_replace(' […]', '…', $s_html);
}
于 2012-09-20T13:10:22.950 に答える
0

ここに記載されています:http://codex.wordpress.org/Function_Reference/the_excerpt_rss「the_excerpt_rss」にフックするため、おそらくこれは機能します:

function new_excerpt_more( $excerpt ) {
    return str_replace( '[...]', '...', $excerpt );
}
add_filter( 'the_excerpt_rss', 'new_excerpt_more' );

それでもうまくいかない場合は、このページでその他の方法を参照してください: http://codex.wordpress.org/Function_Reference/the_excerpt#Remove_.5B....5D_string_using_Filters

于 2012-07-26T12:57:55.537 に答える