By -
陳 瞽鱦
WordPress Continue Reading Target
默认的 WordPress Continue Reading,是在原窗口打开的,这符合多数网友的阅读习惯,如果因为某些原因,比如朋友的力邀,可以临时修改参数。
不过定义窗口类型在程序中两处,最初我以为和主题相关,也的确在主题文件夹的 functions.php 中找到可疑代码:
/* Custom Continue Reading Link */ function romangie_new_excerpt_more( $romangie_more ) { return ' <a class="more-link excerpt-link" href="'. get_permalink( get_the_ID() ) . '">' . __('Continue Reading', 'romangie') . '<span class="glyphicon glyphicon-chevron-right"></span></a>'; } add_filter( 'excerpt_more', 'romangie_new_excerpt_more' );
修改之后,却发现无效,只好用 phpstrom 全文检索,最终在 wp-includes/post-template.php 中找到:
if ( count( $content ) > 1 ) { if ( $more ) { $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1]; } else { if ( ! empty( $more_link_text ) ) /** * Filter the Read More link text. * * @since 2.8.0 * * @param string $more_link_element Read More link element. * @param string $more_link_text Read More text. */ $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\" target=\"_blank\">$more_link_text</a>", $more_link_text ); $output = force_balance_tags( $output ); } }
Tagged : PHP