wordpress-增加最新文章與最新留言的標題字數限制

被我註解起來的為原本的程式碼, 另一行是被我改過的

最新文章的部份:


<li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?> </a></li>
<li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) echo esc_attr(mb_substr(get_the_title(),0,16, "UTF8"))."..."; else the_ID(); ?> </a></li>

最新留言部份:
wp-includes/default-widgets.php
$output .= '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';

變成
$output .= '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s > %2$s', 'widgets'), '<a href="'.esc_url( get_comment_link($comment->comment_ID) ) . '">' .mb_substr(get_comment_author(),0,7,"UTF8"), mb_substr(get_the_title($comment->comment_post_ID),0,10,"UTF8") . '..</a>') . '</li>';

發表迴響

Copy Protected by Chetan's WP-Copyprotect.