J
J
JyriG2018-09-01 15:40:39
WordPress
JyriG, 2018-09-01 15:40:39

Can you help with post thumbnails in Wordpress?

Hello,
Can you please tell me how to display post thumbnails?
Now it looks not very good for me, to put it mildly, here is a screenshot
5b8a884d8bd85001642586.png
And here is the code:

<div class="news news_slider">
<?php 
$arg_cat = array(
'orderby'      => 'name',
'order'        => 'ASC',
'hide_empty'   => 1,
'exclude'      => '',
'include'      => '',
'taxonomy'     => 'category',
);
$categories = get_categories( $arg_cat );
?>

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  <div id="post-<?php the_ID(); ?>" <?php post_class('g post'); ?>>
      
  </div>
<?php endwhile; ?>
<?php 
if( $categories ){
foreach( $categories as $cat ){
$arg_posts =  array(
'orderby'      => 'name',
'order'        => 'ASC',
'posts_per_page' => 9,
'post_type' => 'post',
'post_status' => 'publish',
'cat' => $cat->cat_ID,
);
$query = new WP_Query($arg_posts);
?>
<?php if ($query->have_posts() ) ?>
<h2><?php echo $cat->name; ?> </h2>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="main-page-post">
  <a href="<?php the_permalink(); ?>">
  <?php the_post_thumbnail( 'widgetfull' );?>
  </a>
  <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
<?php endwhile; wp_reset_postdata()?>
<?php		
  }
  }
?>
</div>
.
Ideally, everything should look like this:
5b8a88b20b73b218335492.png
How to make everything as ideal as possible?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question