Advanced Issue With the_title() in a custom loop
Here’s my code:
<?php //do an sql query for posts <?php global $wpdb; /* i found out that this is required in the sidebar! and i think this is somehow relevant to the bigger problem!*/ <?php $querystr = "SELECT * FROM $wpdb->posts" <?php $pageposts = $wpdb->get_results($querystr, OBJECT); ?> // custom loop <? if ($pageposts) : foreach ($pageposts as $post): setup_postdata($post); ?> // loop stuff!!! Number 1: <?php the_title(); ?> Number 2: <?php echo $post->post_title ?> <?php endforeach; ?> <?php else : ?> // if no posts to loop through <?php endif; ?>
this custom loop (used in Daiko’s phptextbox sidebar) fails to call the_title() function during each iteration of the loop
the_title() will display the LAST title found in the whole sql query each time.
echo $post->post_titlewhich displays each post title. but it is very stripped down without all the html formating the_title() adds in.. which is undesirable.
how do i get the_title() to work in this loop?
- The topic ‘Advanced Issue With the_title() in a custom loop’ is closed to new replies.