K
K
kopvi642021-12-08 18:06:45
WordPress
kopvi64, 2021-12-08 18:06:45

How to create a news page in WordPress?

Good day to all!

I recently started doing layout and took an order to create a website.

I ran into a problem with displaying a news block on a page using WordPress. I have a ready-made layout for design, I have already made a theme out of this layout, created an adaptive menu, everything works very well, but I can’t implement the news block, especially so that the news looks the same as in the design.

Here's what they should look like:
61b0c57c8084b027510207.jpeg

And here's what I get:
61b0c5c414a0f970101864.jpeg

And at the same time, if you follow the link to the article, the text and photo that I inserted when creating the post (news) are not displayed:
61b0c826e1553390988433.jpeg

Please tell me how to create a news block correctly, what and in which file to register in the folder with my theme, so that everything works as it should and the client can add new news, otherwise I have already rummaged through half the Internet, but I can’t make it out properly, because I don’t I understand php.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Zolin, 2021-12-08
@kopvi64

To get started, you should familiarize yourself with the template hierarchy . The single.php template is responsible for displaying the post, and archive.php
is responsible for displaying the archive page . or taxonomy.php
For the front page, you should use front-page.php , home.php , or custom if the front page is created using a static page. In index.php - the base cycle
Immediately I advise you to read about the functions wp_query()andget_terms(), they are needed to query records and terms from the database for further processing or output.
For output, you need functions of the following form:

  • the_title()- display title
  • the_post_thumbnail()- display the image of the record
  • the_content()- display content

Look for the rest by analogy
. I also recommend looking at the code of the twenty default themes or any popular ones. By doing this, you will avoid many problems and mistakes. In addition, I recommend installing the query monitor plugin , it shows the stack of loaded templates and a lot of other useful information that will help you when developing.

W
WP Panda, 2021-12-08
@wppanda5

I recently started doing layout and took an order to create a website.

What for? If you cannot do the most trivial task.
For starters, read what a cycle is, a hierarchy of templates, see how other topics are arranged

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question