I would greatly appreciate some help, I have written a loop inside a list item however I'm looking to set a width and height on the thumbnail and display some expert "text" but limit the length of it...

    <!-- Define our WP Query Parameters -->
    <?php $the_query = new WP_Query( 'posts_per_page=3' ); ?>

    <!-- Start our WP Query -->
    <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>


            if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.

        <a href="<?php the_permalink() ?>"><?php the_title(); ?></a>

    <!-- Repeat the process and reset once it hits the limit -->

  • Added a function expert length which has worked! however not sure about the thumbnail I know you can set sizes "large" etc however can I define the height and width? Dec 23, 2018 at 19:37

1 Answer 1


Add this function in your functions.php for specific size of thumbnail

add_image_size( 'custom-size', 220, 180 );

and fetch custom-size image. For excerpt length use this function.

function wp_example_excerpt_length( $length ) {
   return 30; 
add_filter( 'excerpt_length', 'wp_example_excerpt_length');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.