Is it possible to list the output of get_post_type alphabetically in the following:
<?php
$post_type = get_post_type_object( get_post_type($post) ); // GET SINGULAR NAME
$args = array(
'public' => true,
'_builtin' => false
);
$output = 'objects'; // names or objects, note names is the default
$operator = 'and'; // 'and' or 'or'
$post_types = get_post_types($args, $output, $operator);
echo '<select class="selectboxSingle" name="post_type">';
foreach ( $post_types as $post_type ) {
$exclude = array('phase1','phase2');
if(TRUE === in_array($post_type->name,$exclude)){
continue;
}
// Note: I think you need to use query_var here, rather than slug.
echo '<option value="'.$post_type->query_var.'">' . ucfirst($post_type->labels->singular_name) . '</option>';
}
echo "</select>";
?>
Aucun commentaire:
Enregistrer un commentaire