태그 보관물: pluggable

pluggable

자식 테마에서 부모 함수를 재정의하는 방법은 무엇입니까? 할 수없는

나는 주변을 읽고이 작업을 수행하는 방법을 알아 내려고 노력했지만 어떤 이유로 든 내 자식 테마에서 부모 함수를 재정의 할 수없는 것 같습니다.

TwentyTen을 부모로 사용하고 있습니다. 누군가 내 자식 테마의이 함수가 부모 함수를 재정의하지 않는 이유를 말해 줄 수 있습니까?

// Override read more link
function osu_twentyten_continue_reading_link() {
 return ' <a href="'. get_permalink() . '">' . __( 'Read on <span class="meta-nav">&rarr;</span>', 'twentyten-child' ) . '</a>';
}
function osu_twentyten_auto_excerpt_more( $more ) {
 return ' &hellip;' . osu_twentyten_continue_reading_link();
}
remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
add_filter( 'excerpt_more', 'osu_twentyten_auto_excerpt_more' );

필터를 다시 추가하기 전에 필터 / 액션 등을 제거해야한다고 생각 했습니까?

감사,

오스



답변

테마 설정 후 코드를 실행해야합니다.

function osu_twentyten_continue_reading_link() {
    return ' <a href="'. get_permalink() . '">' . __( 'Read on <span class="meta-nav">&rarr;</span>', 'twentyten-child' ) . '</a>';
}

function osu_twentyten_auto_excerpt_more( $more ) {
    return ' &hellip;' . osu_twentyten_continue_reading_link();
}

function my_child_theme_setup() {
    remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
    add_filter( 'excerpt_more', 'osu_twentyten_auto_excerpt_more' );
}

add_action( 'after_setup_theme', 'my_child_theme_setup' );

답변