setup_postdata problem
-
Hi,
I’m trying to get a custom loop written using setup_postdata
but the functions like the_title() are returning nothing.I’ve set up a fresh install of wp 2.3.2 to ensure that no other plugins or theme issues are causing it.
And I’ve paired the code down to the minimum to confirm the issue
Here is the resultant code:
add_management_page("LIST POSTS", "LIST POSTS", 9, basename(__FILE__), MYPLUGIN_show_management_page); function MYPLUGIN_show_management_page() { global $wpdb; $sql = "SELECT $wpdb->posts.* FROM $wpdb->posts LIMIT 0,10"; $pageposts = $wpdb->get_results($sql); ?> <div class="wrap"> <?php if ($pageposts) { $bgcolor = ''; foreach ($pageposts as $pagepost) { setup_postdata($pagepost); echo "<hr>"; echo "<br>ID: " . the_ID(); echo "<br>Title: " . the_title(); echo "<br>Date: " . the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); echo "<br>Categories: " . the_category(','); echo "<br>Author: " . the_author(); } } ?> </div> <? }
What I end up with is:
1 ID: Title: Date: Uncategorized Categories: admin Author: admin2 ID: Title: Date: Uncategorized Categories: admin Author: admin
Any help in getting these functions to work properly would be greatly, greatly appreciated.
Regards,
Andy
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘setup_postdata problem’ is closed to new replies.