Return only certain (html)-elements of the_content()

There are two ways to achieve it.

$args = array(
                'post_type' => 'post',
                'posts_per_page'=>1
             );
   $mj_query = new WP_Query( $args );
  1. By the_expcerpt(), You can use excerpt field to display the content for post listing page.You can enable excerpt field by screen option through current post edit page.Just put html element to that excerpt field and use below code. It will display it as you want.

    while ( $mj_query->have_posts() ) {

        the_excerpt();
    

    }

  2. By get_the_content(), you can get all content of a specific post by get_the_content() function and alter it using substr() function.Here you can use length according to you content to be displayed.

    while ( $mj_query->have_posts() ) {
    
       $theExcerpt = get_the_content();
       echo substr($theExcerpt,0,100);
    

    }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)