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.

In "Main Sidebar" i would like to add a dropdown list of ALL my post. How can i do that? I found various plugins and none of them did what i wanted (for example one only list the post i have on that page).

How might i put all my post into a dropdown/menu list in the sidebar?

share|improve this question

2 Answers 2

up vote 1 down vote accepted
    // query for all posts
    $your_query = new WP_Query( 'posts_per_page=-1' );

    echo '<select>'.
         '<option value="" selected="selected">Select a post</option>';

    // loop through posts
    while ( $your_query->have_posts() ) : $your_query->the_post();
        echo '<option value="';
        echo '">';
        echo '</option>';

    echo '</select>';

    // reset post data

Obviously, that does nothing unless you bind some js/jQuery to the change event.

share|improve this answer

You can show all post w/o jQuery using this bit of code:

<form action="<? bloginfo('url'); ?>" method="get">
<select name="page_id" id="page_id">
global $post;
$args = array( 'numberposts' => -1);
$posts = get_posts($args);
foreach( $posts as $post ) : setup_postdata($post); ?>
    <option value="<? echo $post->ID; ?>"><?php the_title(); ?></option>
<?php endforeach; ?>
<input type="submit" name="submit" value="view" />
share|improve this answer

Your Answer


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.