• peterlunglum

    (@peterlunglum)


    Hi all,

    I’m new to wordpress and am wondering how I can get a post gallery working in my php files. As it is currently I have the following code:

    <?php
    $gallery_atts = array (
    'post_parent' => $post->ID,
    'post_mime_type' => 'image'
    
    );
    
    $gallery_images = get_children($gallery_atts);
    
    if (!empty($gallery_images)) {
    $gallery_count = count($gallery_images);
    $first_image = array_shift($gallery_images);
    $display_first_image = wp_get_attachment_image($first_image->ID);
    ?>	
    
    <figure class="article-preview-image">
    <a href="<?php the_permalink(); ?>" <?php echo $display_first_image; ?> </a> </figure>
    <?php }
    ?>

    This is all for a content gallery php file I’m making for a personal wordpress theme. I’ve been following tutorials and following some intuition, but I’ve run into a wall here as I think some of the sources I’m using may be outdated. Any help is appreciated, thanks!

  • The topic ‘wordpress post gallery test’ is closed to new replies.