Support » Developing with WordPress » Problem Aq_resize in loop

  • Greetings.

    I am not proficient at writing in English, I am using a translator, I hope I can explain properly.

    I have generated a cycle to show the post of a category, this is the code:

    <ul class="category-section">
            <?php $the_query = new WP_Query( $sublimation_data ); ?>
            <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
                <a href="<?php the_permalink(); ?>">
                    <?php if ( has_post_thumbnail() ) {
                                the_post_thumbnail( $sublimation_size );
                            } ?>
                    <a href="<?php the_permalink() ?>">
                        <?php the_title(); ?>
                    <?php excerpt_long($excerpt_numb); ?>
            <?php endwhile;?>

    It works correctly, but I want the image shown to be really cut to a size and not be a virtual measurement, when I inspect the element it tells me that the image shows “360 x 270 px” but the actual measurement is 768×576 and it is shown in url of the image.


    How can I make an aq_resizer correctly and add to the cycle?

    Thanks, I’m new to wordpress and php.

    • This topic was modified 3 months, 2 weeks ago by  singularidad.
    • This topic was modified 3 months, 2 weeks ago by  bcworkz. Reason: code fixed - 1st backtick must be in col 0

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    Welcome to WordPress and the Forums!

    Machine translation is fine. You can even write in your native language if you prefer. Most of use will end up using a machine translation anyway. Hopefully this post will make sense translated back to your language.

    The best way to get the image sized as you want is to either change one of the default sizes in the Settings > Media administration screen; or add another named image size by using add_image_size(). You can specify how uploaded images will be resized or cropped to get the desired size. Then pass the desired size by name to the_post_thumbnail(). For example:
    the_post_thumbnail( get_the_ID(), 'sublimation_image');
    assuming you previously added a “sublimation_image” image size and uploaded the image after adding the size. Images uploaded before adding the new size will not have versions in the new size. There are plugins that can correct this if needed.

    You can also explicitly specify a unique size that is different from any named sizes. Like so:
    the_post_thumbnail( get_the_ID(), [ 500, 375 ]); // 500px wide x 375px high
    To do this properly, you will need to get the image’s original dimensions from the attachment meta data so the proper aspect ratio can be maintained.

    Note that in some cases, the actual image size is determined by CSS, regardless of what image size you request in the_post_thumbnail(). This does not appear to be the case on your home page, but keep this in mind if the requested sizes in PHP do not seem to be working.

    I appreciate the help.

    I will try following your guide.

    Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.