Problems using the Loop in a plugin
-
Hi…I’m trying to use the loop in a plugin to populate a select element. When I call the loop, I’m getting no results. I have many posts on my development setup, but they do not seem to be accessible. I’m trying to run this code in a submenu page in the administration panel.
Here’s the code I’ve been using:
// Get all posts for the select options if(have_posts()) { while(have_posts()) { the_post(); $titles[$post->ID] = the_title(); } }
Also, I’ve played around with using the $wp_query objecy:
global $wp_query; print_r($wp_query);
This code returns:
WP_Query Object ( [query] => [query_vars] => Array ( ) [queried_object] => [queried_object_id] => [request] => [posts] => [post_count] => 0 [current_post] => -1 [in_the_loop] => [post] => [comments] => [comment_count] => 0 [current_comment] => -1 [comment] => [found_posts] => 0 [max_num_pages] => 0 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_404] => [is_comments_popup] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => )
Can anyone help me figure out why I cannot get this post information?
- The topic ‘Problems using the Loop in a plugin’ is closed to new replies.