我收到了来自Wordpress的所有帖子, 但帖子中的文本像这样中断:
换行符的图像
这是一个代码片段:
<?php
global $post;
$args = array(
'posts_per_page' => 10, 'orderby' => 'date'
);
$postslist = get_posts( $args );
if($postslist) {
foreach ( $postslist as $post ) :
setup_postdata( $post );
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$content = apply_filters('the_content', $post->post_content);?>
<h2><?php the_title(); ?></h2>
<p><?php the_date(); ?></p>
<img id="blogtemplate-image" src="<?php echo $url ;?>" />
<p><?php echo $content; ?></p>
<?php endforeach; }
wp_reset_postdata();
?>
如何避免中断并仅获取所有内容?
提前致谢!
#1
我自己找到了答案。不必获取the_excerpt(), 我必须使用the_content()。 The_excerpt仅返回约55个字符:
<?php
global $post;
$args = array(
'posts_per_page' => 10, 'orderby' => 'date'
);
$postslist = get_posts( $args );
if($postslist) {
foreach ( $postslist as $post ) :
setup_postdata( $post );
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
?>
<h2><?php the_title(); ?></h2>
<p><?php the_date(); ?></p>
<img id="blogtemplate-image" src="<?php echo $url ;?>" />
<p><?php echo the_content(); ?></p>
<?php
endforeach;
}
wp_reset_postdata();
?>
评论前必须登录!
注册