Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Currently, I makes a plugin, and I want to display some post in admin submenu, my url looks like

wp-admin/admin.php?page=mypluginpage

how to display posts list on my plugin page? it's possible or not?

Thanks.


Please delete this post, I just found solution:

<?php
$query = new WP_Query(
    array(
        'post_type' => 'post',
        'post_status' => 'publish'
    )
);

$list = array();
foreach ($query->posts as $post) {
    .......
}
?>
share|improve this question
    
Instead of deleting you can just write your solution in an answer and accept it. –  fdsa Aug 13 '12 at 1:26
add comment

1 Answer

Better would be the use of WordPress' function get_posts():

$args = array(
    'post_type' => 'post',
    'post_status' => 'publish'
);

$posts = get_posts( $args );

echo '<ul>';

foreach ( $posts as $post ) {
    echo '<li>' . $post->post_title . '</li>';
}

echo '</ul>';

http://codex.wordpress.org/Template_Tags/get_posts

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.