wordpress - How to use get_posts() and form select -


hi i'm new wp plugin development. far, i'm doing except form select piece seems kicking head. i'm trying show list of recent post in select field admin select , stuff title not show. tried in radio button , text field , got no result. please, missing in form?

<form method="post"><select name="article"> $args = array( 'numberposts' => 10, 'order'=> 'asc', 'orderby' => 'title' ); $postslist = get_posts( $args );     foreach ($postslist $post) : setup_postdata($post);  echo'<option value='".the_id()."'>'".the_title()."'</option>'; endforeach; echo"</select></form>"; 

i can't test right now, there couple of possibilities.

first, the_id() echo value - won't work you'd in middle of concatenation. need get_the_id() instead.

second, matching of quotes seems odd when you're echoing option. assuming want output like

<option value="1">title</option> 

your echo should

echo '<option value="' . get_the_id() . '">' . get_the_title() . '</option>'; 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -