• Hello,

    This code is responsible for displaying thumbnails in the post archive. I discovered that if you specify the exact dimensions in the admin panel and rewrite this code, you can achieve the desired and exact size of the photos to display them in the theme.
    But the problem is that after copying the file to the child theme where this code is located, the code does not work. It needs to be written somehow differently.
    For example, in the function.php file.
    How to do it?

    Full code from \wp-content\themes\zakra\inc\template-tags.php

    if ( ! function_exists( 'zakra_post_thumbnail' ) ) :
    
    	/**
    	 * Displays an optional post thumbnail.
    	 *
    	 * Wraps the post thumbnail in an anchor element on index views, or a div
    	 * element when on single views.
    	 */
    	
    	function zakra_post_thumbnail( $image_size = 'post-thumbnail' ) {
    
    		if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
    
    			return;
    		}
    		?>
    
    		<div class="zak-entry-thumbnail">
    
    			<?php
    			if ( is_singular() ) :
    
    				the_post_thumbnail();
    			else :
    			?>
    
    				<a class="zak-entry-thumbnail__link" href="<?php the_permalink(); ?>" aria-hidden="true">
    					<?php
    					the_post_thumbnail(
    						$image_size,
    						array(
    							'alt' => the_title_attribute(
    								array(
    									'echo' => false,
    								)
    							),
    						)
    					);
    					?>
    				</a>
    			<?php endif; // End is_singular(). ?>
    
    		</div><!-- .zak-entry-thumbnail -->
    		<?php
    	}
    endif;

    From this code

    function zakra_post_thumbnail( $image_size = 'post-thumbnail' )

    to this code

    function zakra_post_thumbnail( $image_size = 'thumbnail' )
Viewing 1 replies (of 1 total)
  • Hi @veri63,

    Thanks for reaching us,

    The thumbnail size does not get changed only by changing the code in the templates-tags file. You need to add the function inside the function.php file, also. Please add the code above you have added above in the template-tags file and add the following code on the function.php file:

    ( ! function_exists( 'zakra_post_thumbnail' ) )

    After adding the code, save the changes and check your front end. The image thumbnail size should be changed.

    Let me know if this helps you or not and I will get back to you.

    Regarda

    • This reply was modified 2 years, 6 months ago by Barsha Paudel.
Viewing 1 replies (of 1 total)

The topic ‘Resizing thumbnails in a child theme’ is closed to new replies.