css - adding additional class to get the post thumbnail

This question already has answers here:Add class name to post thumbnail(4 answers)Closed 5 years ago.I'm just start

This question already has answers here: Add class name to post thumbnail (4 answers) Closed 5 years ago.

I'm just starting to create new theme and i'm new to code. I'm stuck in customizing the post thumbnail code, i tried add

<?php previous_post_link(get_the_post_thumbnail(get_previous_post(), array(
                        'class' =>  'rounded-lg object-cover'
           )) . '<h4 class="text-center">%link</h4>',
           '%title',false
   );
?>

but it doesn't seem to work. did my array mistakenly placed in the code?

This question already has answers here: Add class name to post thumbnail (4 answers) Closed 5 years ago.

I'm just starting to create new theme and i'm new to code. I'm stuck in customizing the post thumbnail code, i tried add

<?php previous_post_link(get_the_post_thumbnail(get_previous_post(), array(
                        'class' =>  'rounded-lg object-cover'
           )) . '<h4 class="text-center">%link</h4>',
           '%title',false
   );
?>

but it doesn't seem to work. did my array mistakenly placed in the code?

Share Improve this question asked Jul 16, 2019 at 0:42 haiz85haiz85 111 bronze badge 4
  • wordpress.stackexchange/questions/102158/… – fja3omega Commented Jul 16, 2019 at 0:51
  • Are you saying it's not working because you can't see the CSS effect you expected to see, or are you saying it's not working because the class attribute does not have those classes when you inspect the HTML? – Jacob Peattie Commented Jul 16, 2019 at 1:06
  • 2 2nd argument is thumbnail size (usually 'post-thumbnail') so if you add that the attributes will shift to their correct (3rd) argument position and should be all good. developer.wordpress/reference/functions/… – majick Commented Jul 16, 2019 at 1:12
  • guys sorry, i think i already fix it, and now i have problem with customizing image width and height, here are my latest code. – haiz85 Commented Jul 16, 2019 at 1:32
Add a comment  | 

2 Answers 2

Reset to default 1

Sorry for late reply, already fixed, i miss understood about array, so here the code that completely run as i want it.

 <?php
 $next_post = get_next_post();
  next_post_link('%link',
     get_the_post_thumbnail($next_post->ID, 'prev_next_img', array(
               'class' => 'rounded-lg object-fill w-full max-h-full' 
     )) . '<h4 class="text-center mt-2 lg:text-base text-sm no-underline text-black leading-snug font-medium">%title</h4>',                                                
     false);
 ?>

in function.php

i put custome image size

add_image_size('prev_next_img', 370, 270, true);

i think i already fix it, and now i have problem with customizing image width and height, here are my latest code.

 $prev_post = get_previous_post();
 previous_post_link(
 get_the_post_thumbnail($prev_post->ID, 'custom-size-image', array(
         'class'     =>  'rounded-lg object-cover',
         'sizes'     =>  'width="371" height="270"'
 )) . '<h4 class="text-center">%link</h4>',
 '%title',
 false
 );

but 'sizes' part doesn't seem to work, please help

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745308703a4621870.html

相关推荐

  • css - adding additional class to get the post thumbnail

    This question already has answers here:Add class name to post thumbnail(4 answers)Closed 5 years ago.I'm just start

    18小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信