Forum Replies Created

Viewing 1 replies (of 1 total)
  • divyagoel2k7

    (@divyagoel2k7)

    To create thumbnails of posts and display them in a page say your blog page(which in my case is not home page), you need to go and check your functions.php file. Search for add_theme_support( 'post-thumbnails' );
    If it is not present then go to your theme’s child folder and add functions.php file. Add `/**
    * Enable support for Post Thumbnails
    */
    add_theme_support( ‘post-thumbnails’ );

    add_image_size(‘featured’, 690, 462, true);`
    and save file.
    Now copy your page.php and paste it in your child folder. Rename it to page-blog.php and append below code

    <?php
    /*
    Template Name: Blog
    */
    ?>
    $myposts = get_posts('');
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
      <div class="post-item">
        <div class="post-info">
          <h2 class="post-title">
          <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
          <?php the_title(); ?>
          </a>
          </h2>
          <p class="post-meta">Posted by <?php the_author(); ?></p>
        </div>
        <div class="post-content">
        <?php the_post_thumbnail(); ?>
        </div>
      </div>
    <?php comments_template(); ?>
    <?php endforeach; wp_reset_postdata(); ?>

    Create a new page from wordpress panel and select template as blog. Publish it. You’ll now see thumbnails of posts..

Viewing 1 replies (of 1 total)