• Resolved Tom Auger

    (@tomaugerdotcomyahooca)


    Because the code was getting really ugly, I converted the typical <?php while():?> <?php endwhile ?> format that you typically see the loop in to the standard php block format while() { …. }

    Things have begun to behave very strangely, and since I’m new to WordPress development I thought maybe there’s a reason why.

    Here’s my code:

    query_posts('cat='.$category->term_id.'&showposts=5');
    while (have_posts()){
    	the_post();
    	echo '<li><a href="' . the_permalink() .'" rel="bookmark" title="' . the_title() . '">';
    		echo the_title() . '</a>';
    	echo '</li>';
    }

    What is happening is for the first 3 posts, the title and permalink are appearing OUTSIDE (before) the <a> tag. I have no idea how it’s doing that – there’s nothing obvious to me in my php that would cause this odd behaviour. Strangely, (even more strangely, I should say), the last 2 posts ARE appearing as expected within the <a href="" title=""> parts.

    Any explanation would be appreciated to help me understand.

    Regards,

    Tom

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using standard-style PHP blocks for The Loop’ is closed to new replies.