在214主题中,有一个名为twentyfourteen_excerpt_more
这将生成“阅读更多”链接。可以在子主题中重写此函数,以使用自定义的“阅读更多”链接。您只需将以下内容添加到子主题的函数中即可。php文件:
/**
* Overrides the parent function that generates the read more links
*
* @param string $more
*
* @return string
*/
function twentyfourteen_excerpt_more( $more ) {
global $post;
return \'<a class="more-link" href="\'. get_permalink($post->ID) . \'">Fortsett å lese</a>\';
}
add_filter( \'excerpt_more\', \'twentyfourteen_excerpt_more\' );
仅供参考,父函数位于
twentyfourteen/inc/template-tags.php
看起来是这样的:
if ( ! function_exists( \'twentyfourteen_excerpt_more\' ) && ! is_admin() ) :
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ...
* and a Continue reading link.
*
* @since Twenty Fourteen 1.3
*
* @param string $more Default Read More excerpt link.
* @return string Filtered Read More excerpt link.
*/
function twentyfourteen_excerpt_more( $more ) {
$link = sprintf( \'<a href="%1$s" class="more-link">%2$s</a>\',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( \'Continue reading %s <span class="meta-nav">→</span>\', \'twentyfourteen\' ), \'<span class="screen-reader-text">\' . get_the_title( get_the_ID() ) . \'</span>\' )
);
return \' … \' . $link;
}
add_filter( \'excerpt_more\', \'twentyfourteen_excerpt_more\' );
endif;