• Feeling kind of dumb right now. On my home page there is a grid, 2 rows with 4 blocks in each row. For the top row I want to display an image pulled from a post and the post’s title, from the 4 most popular posts. For the bottom row, I want to do the same for the 4 most recent posts. Thanks for any help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • What theme are you using? Where did you download it from?

    Thread Starter justin.garner23

    (@justingarner23)

    It’s actually a theme I’m building myself, based off Bootstrap. Here’s the code for one of my rows:

    <div class="row-fluid">
      <ul class="thumbnails">
        <li class="span3">
          <a href="#" class="thumbnail">
            <img src="https://placehold.it/300x250&text=placeholder">
            <h4 class="text-center">category</h4>
          </a>
        </li>
      </ul>
    </div>

    I’d like the link to be a link to the post, the image to an image pulled from that post and the h4 to be the title.

    Thanks for the quick response!

    Thread Starter justin.garner23

    (@justingarner23)

    Update:

    Thanks again for the response! I made a few changes to my code:

    <?php query_posts("post_per_page=6"); the_post(); ?>
    <li class="span2">
      <a href="<?php the_permalink();?>" class="thumbnail">
        <img src="https://placehold.it/300x250&text=placeholder">
        <h4 class="caption text-center"><?php the_title();?></h4>
      </a>
    </li>

    Now I’m pulling the link and title! I’m almost where I’d like to be, just lacking the image from the post. I’m reading and researching in hopes of figuring it out (and learning more along the way!), but if anybody happens to know the route I need to take, it would be much appreciated.

    Thread Starter justin.garner23

    (@justingarner23)

    Oh and I just thought I’d add that when I’ve worked through getting this up and running I intend to publish it to the WP theme directory. I don’t plan on using this theme to make money, I want to spread it and see what kind of awesomeness can be made with it!

    Thread Starter justin.garner23

    (@justingarner23)

    OK! New update. Figured it all out! The code below did exactly what I was wanting. When I finish the site I’ll come back and link to it so you can see what I was going for.

    <div class="row-fluid">
      <ul class="thumbnails">
        <?php
          $popular = new WP_Query('orderby=comment_count&posts_per_page=4');
        ?>
        <?php while ($popular->have_posts()) : $popular->the_post(); ?>
          <li class="span3">
            <a href="<?php the_permalink() ?>" class="thumbnail">
              <?php the_post_thumbnail(array(300,250)); ?>
              <h3 class="caption text-center"><?php the_title();?></h3>
            </a>
          </li>
        <?php endwhile; ?>
      </ul>
    </div>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Calling Post Titles & Images’ is closed to new replies.