Answer the question
In order to leave comments, you need to log in
How to write php code (in wordpress | post-thumbnails) to make it work?
Help, please, to solve the problem:
You need to get something like this:
In functions.php connected: add_theme_support( 'post-thumbnails' );
Below I give the same lines of output, but something is not right in them.<img src='mysite.ru/ava.png' alt='текст'>
<?php
$args = array(
'numberposts' => '0',
'category_name' => 'comments',
'order' => 'ASC',
'post_type' => 'post',
'suppress_filters' => true,
);
$posts = get_posts( $args );
foreach($posts as $post){setup_postdata($post); ?>
<?php echo "<img class='media-object' src='" . get_the_post_thumbnail_url() ."' alt='" . the_field( 'comment_client' ) . "'>";?>
<img class="media-object" src="<?php get_the_post_thumbnail_url();?>" alt="<?php the_field( 'comment_client' ); ?>">
<?
}
wp_reset_postdata();
?>
<img class='media-object' src='https://mysite.ru/wp-content/uploads/2018/06/ava.png' alt=''>
<img class="media-object" src="" alt="Иванов Иван, Москва">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question