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