Answer the question
In order to leave comments, you need to log in
How to add the ability to upload multiple images in WordPress?
How to add the ability to upload multiple images for a post? Those. so that you can choose not a post thumbnail, but several images. And then naturally how to display them?
Answer the question
In order to leave comments, you need to log in
I recommend looking towards the PODS plugin . It allows you to create new post types or extend existing ones.
In your case, you need to add a new field to add your images to the post.
Procedure:
1) Install the plugin
2) In the admin panel POD Management > Add New > Extend Existing.
3) In the content type field, select: post types, and in the post type - records. We create.
4) Add a new field of type File / Image / Video. Enter a caption and a name, for example, images. In the advanced settings of the field, select Upload Limit: Multiple Files. We save.
5) We proceed to editing the post and see that it is possible to attach additional images.
6) Чтобы вывести изображения в нужным месте используйте следующий код:
if ( get_post_meta( get_the_ID(), 'images', false ) ){ //images название вашего произвольного поля
$image_array = get_post_meta( get_the_ID(), 'images', false ); //images название вашего произвольного поля
}
if ( $image_array ) {
foreach ( $image_array as $image ) {
$thumbimg = wp_get_attachment_image( $image['ID'], 'thumbnail');
$fullimg = pods_image_url( $image['ID'], 'large');
echo '<a href="'. $fullimg . '">' . $thumbimg . '</a>';
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question