Replies: 0
Iam trying to make a grid style home page. For that I created front-page.php with below code. But thumbnails not showing. If I set featured thumbs it will work. How to show thumbails in home page without setting featured thumbs in each posts.
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package understrap
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
get_header();
$container = get_theme_mod( 'understrap_container_type' );
?>
<?php if ( is_front_page() && is_home() ) : ?>
<?php get_template_part( 'global-templates/hero' ); ?>
<?php endif; ?>
<div class="wrapper" id="index-wrapper">
<div class="<?php echo esc_attr( $container ); ?>" id="content" tabindex="-1">
<main class="site-main row" id="main">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-md-4">
<?php
the_title(
sprintf( '<h2 class="entry-title" style="margin-bottom:1em"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ),
'</a></h2>'
);
?>
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
<?php if ( 'post1' == get_post_type() ) : ?>
<div class="entry-meta">
<?php understrap_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif; ?>
<div class="entry-content">
<?php the_excerpt(); ?>
<?php
wp_link_pages(
array(
'before' => '<div class="page-links">' . __( 'Pages:', 'understrap' ),
'after' => '</div>',
)
);
?>
</div><!-- .entry-content -->
</div>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'loop-templates/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
<!-- The pagination component -->
<?php understrap_pagination(); ?>
</div><!-- #content -->
</div><!-- #index-wrapper -->
<?php get_footer(); ?>