• henballs

    (@henballs)


    How do I customize the size of the blog images on my main blog page? I want the first three images to be large and the rest to be small. How is this done?

    Here’s the code

    <?php get_header(); ?>
    
    <div class="container">
        <div class="main-content">
          <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
            <div <?php post_class() ?>>
              <h2>
                <a href="<?php the_permalink() ?>">
                  <?php the_title(); ?>
                </a>
              </h2>
              <?php the_content(''); ?>
            </div>
          <?php endwhile; ?>
          <?php endif; ?>
        </div>
    </div>

Viewing 1 replies (of 1 total)
  • graphical_force

    (@graphical_force)

    You need to add some image sizes in your functions.php file http://codex.wordpress.org/Function_Reference/add_image_size

    Once done, you can do something like this:

    <?php get_header(); ?>
    
    <?php $postCounter = 0; ?>
    <div class="container">
        <div class="main-content">
          <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
            <?php if ($postCounter < 3) { ?>
            <div <?php post_class() ?>>
              <h2>
                <a href="<?php the_permalink() ?>">
                  <?php the_title(); ?>
                </a>
              </h2>
              <?php the_post_thumbnail('LARGE_THUMB_NAME'); ?>
              <?php the_content(''); ?>
              <?php $postCounter = $postCounter + 1; ?>
            </div>
    } else {
            <div <?php post_class() ?>>
              <h2>
                <a href="<?php the_permalink() ?>">
                  <?php the_title(); ?>
                </a>
              </h2>
              <?php the_post_thumbnail('SMALL_THUMB_NAME'); ?>
              <?php the_content(''); ?>
    <?php $postCounter = 1; ?>
            </div>
    <?php } ?>
          <?php endwhile; ?>
          <?php endif; ?>
        </div>
    </div>

Viewing 1 replies (of 1 total)

The topic ‘How to change the size of my blog post images??’ is closed to new replies.