php – Problems customizing blog posts on the home page

I can not understand. I'm trying to load in the 6 most recent blog posts (2 rows, 3 columns, responsive). The title of the article would appear above the thumbnail. Here is the sample design (screen capture): https://i.imgur.com/3WQHB8O.png

My original essay was:



<img src = "http://wordpress.stackexchange.com/"style =" width: 100%; ">

What I used the same way on a different site, but never on the home page. While I was looking for why this code did not retrieve the title and thumbnail of the publications but rather from the homepage, I discovered the information below.

I found here an answer that I felt similar and I tried it, but it does not work properly and I do not know how to fix it:


    & # 39; & # 39 ;, post
& # 39; posts_per_page & # 39; => 6
)
$ the_query = new WP_Query ($ args);
// The loop
if ($ the_query-> have_posts ()) {
while ($ the_query-> have_posts ()) {?>
    
<? php if (has_post_thumbnail ()) { echo & # 39;& # 39 ;; } other { echo & # 39;& # 39 ;; }?>
the post office(); echo & # 39;

& # 39 ;. get_the_title (). & # 39;

& # 39 ;; ?>

Here is how the second code ends up appearing, where the titles of the articles are not on the correct images and where everything seems messed up: https://i.imgur.com/6KgKBQi.png

If anyone could help me, I would greatly appreciate it.