0

网址: http: //litepanels.com/blog/

博客文章中的一些摘录在摘录末尾的中间被切断了线条,因此字母看起来被切成了两半。(例如第 3 个向下)因为我定义了一个高度,而紫色标题可以是 1、2、3 或 4 行加上常规复制文本,这会导致不同的高度。

有什么可以帮助解决这个问题的吗?

4

2 回答 2

0

由于发生这种情况是因为标题跨越 3 行 - 一种可能的方法是检查标题的大小,然后从那里调整摘录。

所以在你的functions.php中

这将调整摘录大小 - 如果标题跨越 3 行,则使其成为您想要的数量

function excerptlength($length) {
    return 50; //enter your desired ammount
}
function short_excerpt($length_callback='excerptlength') {
    global $post;
    if(function_exists($length_callback)){
        add_filter('excerpt_length', $length_callback);
    }
    $output = get_the_excerpt();
    $output = apply_filters('wptexturize', $output);
    $output = apply_filters('convert_chars', $output);
    echo $output;
}

然后添加这个 - 它计算标题的大小,如果它超过 70(或您想要的数量),那么摘录将显示我们在上一个函数中设置的摘录的自定义大小

function custom_excerpt(){
$title = get_the_title();
$limit = "70"; //enter your desired ammount
$more="...";
if(strlen($title) <= $limit) {
the_excerpt();
} else {
short_excerpt();
}
}

最后在博客文章中添加这个而不是the_excerpt

<?php custom_excerpt(); ?>
于 2013-07-03T23:03:03.570 回答
0
your post Query on <?php the_content(); ?>  to use this code.

20(替换您定义要显示的字数)

<p><?php $words = explode(" ",strip_tags(get_the_content())); 
$content = implode(" ",array_splice($words,0,20)); echo $content; ?></p>
<?php  if($words): ?>
<p class="more"><a href="<?php echo the_permalink();?>">Read More</a></p>
<?php endif;?>


on your css style_main.css line 97:

.post .entry {
    float: left;
    max-height: 128px;
    overflow: hidden;
    width: 515px;
}

remove :
max-height: 128px;
overflow: hidden;
于 2013-07-04T04:30:25.333 回答