Support » Fixing WordPress » WordPress the_title displays page title

  • Resolved ronnyrook

    (@ronnyrook)


    Hello WordPress Users,

    I’m currently using the following code to display posts:

    $args_blog = array( 'numberofposts' => 10, 'category' => 2, 'orderby' => 'post_  date' );
    $list_of_blog = get_posts( $args_blog );
    
    foreach($list_of_blog as $blog) :
        setup_postdata( $blog ); 
    
        if( has_post_thumbnail( $blog->ID ) ) :
            $image_blog = wp_get_attachment_image_src( get_post_thumbnail_id( $blog->ID ), 'single-post-tumbnail');
    
             if( $image_blog ) :
                 echo '<img src="'.$image_blog[0].'" class="img" width="290" height="290" />';
              endif;
    
        endif; 
    
        the_title();
        the_excerpt();
    endforeach;

    The content and the image of the post are working.
    But the_title is showing the title of the page?

    What can I do about this or is this just a bug or something?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress the_title displays page title’ is closed to new replies.