【发布时间】:2015-02-20 19:56:01
【问题描述】:
我正在制作一个包含帖子的主页,有时帖子只有特色图片而没有内容,有时帖子同时包含特色图片和内容。当帖子有可用内容时,我想用阅读更多按钮显示帖子的摘录。我添加了一个阅读更多按钮,但它甚至与没有任何内容的帖子一起显示。只有当有可用于内容的摘录时,我才能显示它。这是摘录 div 的代码。
<div class="entry-excerpt">
<?php
if( strlen( $post -> post_excerpt . $post -> post_content ) > 0 ){
?>
<div class="excerpt">
<?php
if( is_user_logged_in () ){
the_excerpt();
echo '<a href="' . get_permalink() . '" title="' . __('Continue Reading ', 'cosmotheme') . get_the_title() . '" rel="bookmark">Continue Reading</a>';
}else{
$meta = meta::get_meta( $post -> ID , 'settings' );
if( isset( $meta['safe'] ) ){
if( !meta::logic( $post , 'settings' , 'safe' ) ){
the_excerpt();
echo '<a href="' . get_permalink() . '" title="' . __('Continue Reading ', 'cosmotheme') . get_the_title() . '" rel="bookmark">Continue Reading</a>';
}
}else{
the_excerpt();
}
}
?>
</div>
<?php
}
?>
</div>
【问题讨论】:
标签: php wordpress wordpress-theming