Support » Themes and Templates » Images in post above post title

  • Resolved Sinopa


    Does anyone know how I can get the all images in a post to display above the post title? Been searching, but found no good solutions 🙁

Viewing 8 replies - 1 through 8 (of 8 total)
  • You would need to modify the content or loop file, it would also depend on the theme you are using.

    It is not a normal request, are you using the [gallery] shortcode to group the images?



    No I’m not using the [gallery] shortcode and I knew I would have to modify the loop/content. But I don’t know how.

    I’m working on a template for a customer and they just want to upload images to a post and add some text and a post title, but they want the title below the images. I have seen it done before, but I just don’t know how to do it.

    Are the images inside the post content or attached to the post?

    If they are in the post content then just move the post title below the content and before the comments, in the single page loop.

    If you mean find all attachments and output these then that is a different process, have a look at the codex example and output the images instead of links.

    Both of these would be in single.php


    They are inside the post.
    If I move the title below content, then the post text will also be above the title. I just want the images above the title. Not the text. So that will not work.

    I’m actually closer to a solution with a little help from Google. The only problem now is that it only shows the first picture. If the post have several pictures it doesn’t show them all.


    function catch_that_image() {
      global $post, $posts;
      $first_img = '';
      $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
      $first_img = $matches [1] [0];
      if(empty($first_img)){ //Defines a default image
        $first_img = "/images/default.jpg";
      return $first_img;


    <img src="<?php echo catch_that_image() ?>" />
     <?php the_title(); ?>
                 <?php the_excerpt(); ?>

    The code example above would work for this, I will have a look this evening (UK) and see if I can create a quick function for you, it might be of use for someone else!

    As you are using excerpt and index.php can you post all of index.php up to



    Based on the codex plus a bit extra, three thumbnail images across, change for what you want!

    This goes in functions.php

    This goes in style.css

    To call the function in the “content.php” “loop.php” above the post class

    <?php dr_Get_Post_Images(); ?>

    This is it after rebulding the thumbnails in twenty eleven to generate the new image size.



    Thank you so very much Digital Raindrops 🙂

    Sorry that I haven’t answered you, but been a way for a couple of days and wordpress was the last thing on my mind yesterday 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Images in post above post title’ is closed to new replies.