php - Show a list of titles of all the custom posts in backend -
in wordpress theme, there's custom post type called "slider
".
so, need sliders select box in theme options page. so, user can select slider wants display.
how done ?
never mind, found myself
<?php $type = 'sliders'; // whatever post type $args=array( 'post_type' => $type, 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new wp_query($args); //check if there posts if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <select> <option><?php the_title(); ?></option> </select> <?php endwhile; } wp_reset_query(); // restore global post data stomped the_post(). ?>
Comments
Post a Comment