admin管理员组文章数量:1122846
I'm looking to show a gallery list ( 1 pic + title of gallery + link to gallery) on one page.
I have catch id galleries... it's good for the first line. I've Pic + title + link But for the second... the code show just pic (no title, no link)
Can you help me
$loop = new WP_Query(array(
's' => '[envira-gallery',
'search_columns' => array('post_content')
));
$loop1 = array();
while($loop->have_posts()) :
$loop->the_post();
$loop1 = the_ID();
endwhile;
wp_reset_postdata();
$args = array(
'post_type' => array('page'),
'orderby' => 'ASC',
'post__in' => $loop1
);
//---- ici je traite pour récupérer l'id de la galerie (parent_post) ---//
$loop2 = new WP_Query($args);
while ($loop2->have_posts()) :
$loop2->the_post();
$chaine = get_the_content();
$array = explode('"', $chaine);
$idar= $array[1];
$images =& get_children(array(
'post_parent' => $idar,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'posts_per_page' => 1
));
if (empty($images)) {
echo "pas d'image";
} else {
foreach ($images as $attachment_id => $attachment) {
echo '<a href="'.get_permalink($post->ID).'"><img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'"></a>';
echo get_the_title($post->ID);
}
}
endwhile;
本文标签: loopshow title and displaying link gallery
版权声明:本文标题:loop - show title and displaying link gallery 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736298787a1930301.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论