public static function select_post($args = array()) { $name = self::get_name($args); $value = isset($args['value']) ? trim($args['value']) : ''; $field_class = isset($args['field_class']) ? trim($args['field_class']) : ''; $label = isset($args['label']) ? $args['label'] : ''; $post_type = isset($args['post_type']) ? $args['post_type'] : 'post'; $query_args = array('post_type' => $post_type, 'posts_per_page' => -1); global $post; $tmp = $post; $query = SB_Query::get($query_args); if ($query->have_posts()) { ?> <p> <label for="<?php echo esc_attr($name); ?> "><?php echo $label; ?> :</label> <select class="<?php echo $field_class; ?> " id="<?php echo esc_attr($name); ?> " name="<?php echo esc_attr($name); ?> " autocomplete="off"> <option value="0" <?php selected(0, get_the_ID()); ?> >--<?php _e('Choose', 'sb-core'); ?> <?php echo SB_PHP::uppercase_first_char($post_type); ?> --</option> <?php while ($query->have_posts()) { $query->the_post(); ?> <option value="<?php the_ID(); ?> " <?php selected($value, get_the_ID()); ?> ><?php the_title(); ?> </option> <?php } wp_reset_postdata(); ?> </select> </p> <?php } $post = $tmp; }