Show Images from Post or Page Attachments
Tento článek (nebo jeho část) je převzat z externího zdroje. Je tedy slušností jej uvést včetně případného autora.
Get all image attachments from a page or post. I usually use this to show a slideshow on a page.
I also put how to get the title of the attachment (but I commented it). You can customize how the image will show.
CODE SNIPPET:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php $argsThumb = array( 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null ); $attachments = get_posts($argsThumb); if ($attachments) { foreach ($attachments as $attachment) { //echo apply_filters('the_title', $attachment->post_title); echo '<img src="'.wp_get_attachment_url($attachment->ID, 'thumbnail', false, false).'" />'; } } ?> |
Napsat komentář