Display image attached to post
-
Hey all,
I have a page that displays the profile of a random member of staff (all details taken from a Post), which is reasonably simple. Each of these staff members can have images attached to them, and I would like to display the first attached image in the gallery of the randomly displayed post. Trouble is, I have no idea how to do this!
Any help would be appriciated.
Thanks.
<!-- Random employee displayed here --> <div class="pinkLinks floatLeft staffPreview"> <?php global $post; $randomStaff = get_posts('numberposts=1&category=64&orderby=rand'); foreach($randomStaff as $post) : setup_postdata($post); ?> <h2 href="<?php the_permalink(); ?>"><?php the_title(); ?></h2> <? $content = explode('.', strip_tags(get_the_content())); $content = $content[0]; ?> <p><?php echo $content; ?>. <a href="<? the_permalink(); ?>">Read more...</a></p> <br /> <h3 class="pink">Services Offered</h3> <ul class="staffPageSmallContent"> <?php $all_cats = get_the_category(); foreach($all_cats as $category){ if ($category->category_parent == "51" || $category->category_parent == "38"){ $categories[] = $category; } } if(!empty($categories)){ foreach($categories as $category){ $guid = $wpdb->get_var('SELECT guid FROM '.$wpdb->posts.' WHERE post_title="'.$category->cat_name.'" AND post_type="post"'); if ($category->category_parent == "51" || $category->category_parent == "38"){ echo '<li><a href="'.$guid.'">'.$category->cat_name.'</a></li>'; } } } endforeach; ?> </div>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Display image attached to post’ is closed to new replies.