2011-07-01 46 views
1

在一些网站上,如果您单击某篇文章中的图像,则会在底部的帖子中显示图像。我如何复制这种行为?单独页面中的图像与底部的其他图像

我有这段代码但我不知道它是否正确。我甚至不知道在哪里添加这个。任何人都可以帮助解释准确添加的位置吗?

$attachments = get_children(array('post_parent' => $post->ID, 
         'post_status' => 'inherit', 
         'post_type' => 'attachment', 
         'post_mime_type' => 'image', 
         'order' => 'ASC', 
         'orderby' => 'menu_order ID')); 

foreach($attachments as $att_id => $attachment) { 
    $full_img_url = wp_get_attachment_url($attachment->ID); 
    // Your Code here 
} 

回答

0

你正在描述的是“画廊”的默认功能,例如, twentyten默认主题(因为我不会误解你)。在或围绕loop.php文件的第58行,你会发现:

<?php /* How to display posts of the Gallery format. The gallery category is the old way. */ ?> 

的代码之后,应该给你如何实现提及的外观提示。

将图片添加到帖子时,WP通常会将其包装到您的链接中,指向这种类型的表示。