😁Get all attachment image from post (ok)
https://wordpress.stackexchange.com/questions/393030/how-to-get-all-attachment-image-from-post-wordpress
C:\xampp82\htdocs\wp3\wp-content\themes\gutener-child\attachment.php

<?php
/*
* Template Name: Gallery Page
*/
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => -1,
);
$query_images = new WP_Query($query_images_args);
?>
<?php get_header(); ?>
<div class="main">
<div class="row">
<?php foreach ($query_images->posts as $image) { ?>
<div class="col-md-3">
<img src="<?php echo wp_get_attachment_url($image->ID); ?>">
<a href="<?php echo wp_get_attachment_url($image->ID); ?>" download>Download</a>
</div>
<?php } ?>
</div>
</div>
<?php get_footer(); ?>
Previous😎 Edit blocks widget default, widget default (ok)NextHow to Customize the URL of Attachments in WordPress (ok)
Last updated
Was this helpful?