mercredi 11 septembre 2019

My php if-while loop skips a line of code

The problem is as follows, My query is skipping a part of my loop. i have a query that makes a anchor with the title and thumbnail of the post. it runs the query fine for the first post except for the second post it does not load in the thumbnail, but it does show the title, and the title is only mentioned after the thumbnail, There is no small image that resembles it cant be found either. My first question posted on here so apolagies for misplacing items in the wrong sections.

<?php


// WP_Query arguments
$args = array (
'post_type'              => array( 'klantcase' ),
'post_status'            => array( 'publish' ),
'nopaging'               => true,
'order'                  => 'ASC',
'orderby'                => 'menu_order',
);

// The Query
$klantcases = new WP_Query( $args );

// The Loop
if ( $klantcases->have_posts() ) {
    while ( $klantcases->have_posts() ) {
    $klantcases->the_post();
        echo "<a href=".get_the_permalink().">";
        echo get_the_post_thumbnail( null, $size = 'post-thumbnail');?><br><?php
        echo the_title();?><br><?php
        echo "</a>";
    }
} else {
    echo "no posts found";
}
// Restore original Post Data
wp_reset_postdata();

Now there is probably many ways to improve this loop but as mentioned im very new to all of this. That said i'd love to hear how you guys would resolve this issue.

Aucun commentaire:

Enregistrer un commentaire