Maiken B. Madsen
Maiken B. Madsen

Reputation: 43

Post text breaks in post with [...] Wordpress development

I am receiving all posts from Wordpress but the text in the posts breaks like this:

Image of the line break

Here is a code snip:

<?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();
?>

How can I avoid the break and just getting all the content?

Thanks in advance!

Upvotes: 1

Views: 31

Answers (1)

Maiken B. Madsen
Maiken B. Madsen

Reputation: 43

I found the answer myself. Instead of getting the_excerpt() I have to use the_content(). The_excerpt return only 55 characters or so:

<?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();
 ?>

Upvotes: 2

Related Questions