2017-02-13 6 views
0

Remove_filter()で問題が発生しています。削除フィルターは機能しますが、100%ではありません。最初は削除しません。3 dots続きを読むから、親の抜粋を置き換えません。Wordpress remove

はもっと明確に私が何をしようとしています何を、[...]続きを読むとにそれを変更を削除することです。

これは、子テーマから行われます。

BeforeAfterのスクリーンショットを示します。

親テーマのfunctions.phpコード

function new_excerpt_more($more) { 
    global $post; 
    return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More! &raquo;'  . '</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'); 
+0

問題をはっきりと指定してください。 –

+0

@HappyCoding、私はそれを編集しました –

答えて

2

コードを少し更新するだけで済みます。

// Changing excerpt more 
function new_excerpt_more($more) { 
    global $post; 
    remove_filter('excerpt_more', 'new_excerpt_more'); 
    return ' <a class="read_more" href="'. get_permalink($post->ID) . '">' . ' do whatever you want to update' . '</a>'; 
} 
add_filter('excerpt_more','new_excerpt_more',11); 

フックのデフォルトの優先順位は、それ故、それはない、親テーマのフックが第二追加される可能性があり、あなたのフックと親フックの両方が同じ優先順位を持っている意味が、親のが最後に来た10です。変更を反映します。

+0

まだ同じですが、3つのドットが残っています。そこに書き込むものは変わらないだろう。 –

+0

フック優先度を11に更新します。結果を確認してください –

+0

、ありがとうございます! :)。 –