V
V
Vyacheslav Borgomotov2016-04-21 13:53:31
WordPress
Vyacheslav Borgomotov, 2016-04-21 13:53:31

How to make such output of record?

Good afternoon everyone. Help to realize
in the record there is only 1 picture. the following output is required:

<a href="(ссылка на изображение в посте)"><img src="(миниатюра поста)" alt="" title="(заголовок поста)"/></a>

and is that even possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TraiDeR, 2016-04-21
@v-borgomotov

Try inserting the following code into your template inside the loop:

<a href="<?php the_post_thumbnail_url('full'); ?>">
   <img src="<?php the_post_thumbnail_url('thumbnail'); ?>" alt="" title="<?php the_title(); ?>"/>
</a>

Thumbnail sizes can be set as a string, it accepts the following parameters - thumbnail, medium, large, full.
You can also specify the dimensions with an array, such as array(1024,1024).
There is a possibility that you will have to regenerate thumbnails for already created posts, you can do this with the Regenerate Thumbnails
plugin . It is best to declare your thumbnail sizes in the functions.php file of your WordPress template:
The first parameter is the name of the size, the second and third are the dimensions themselves, the fourth parameter is the cropping. You can read more about the function here .
After declaring a new image size in the_post_thumbnail_url function, you can use the names you registered. This method, in my opinion, is correct, so if you need to resize thumbnails, you will only need to change these sizes in one place, in the functions.php file. Then, most likely, the plugin will need to recreate the thumbnails.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question