I have a site with several thousand posts. They all have just a single attached image of varying size. All posts are displayed in full (no thumbnail view). I'd like to be able to change the way the elements display within the posts to be:

  • date (at the top)
  • image caption
  • the attached image (actual size)
  • post title
  • post text content
  • tags
  • 1
    I'm slightly confused: you indicate that the posts have only a "single attached image", but you list "post text content" in the list of content to output. The answer very likely will vary, based on whether or not you need to output the post text content. – Chip Bennett Nov 11 '12 at 18:50

Something like (in your single.php)

<?php while (have_posts()): the_post(); ?>
  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <time class="post-time" datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('F j, Y'); ?></time>
    <?php if (has_post_thumbnail()): ?>
      <?php $thumbnail_image = get_posts(
          'p' => get_post_thumbnail_id($post->ID),
          'post_type' => 'attachment',
        <p class="thumbnail-caption"> <?php echo $thumbnail_image[0]->post_excerpt; ?></p>
      <?php the_post_thumbnail('full'); ?>
    <?php endif; ?>
      <h1 class="post-title"><?php the_title(); ?></h1>
    <?php the_content(); ?>
      <p class="post-tags"><?php the_tags(); ?></p>
<?php endwhile; ?>

I haven't tested the image caption bit: let me know if it doesn't work, or if you don't dig the markup.

| improve this answer | |

I was unable to understand if that refers to the frontend or the backend?

The backend could be managed by rearranging the metaboxes with the specific content, you can even move the publishing box on the right to the big area on the left.

For the frontend, you'll probably need to design an extra page template that lists posts if it is a single page (you mentioned 'thumbnail' already) so that a page lists several posts with whatever you need from some query, identically to index.php.

If you want to restructure the default single post view, then create a template single.php (or edit the existing one, should your theme inherits that) and construct the HTML markup as needed, in the order and number of fields required.

See the Template Hierarchy link for better understanding of the template calling order.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.