How to change the display order of Dropdown Values (Categories) that are reflecting from DB.
We want to change sequence/display order of Categories in php. We are using "accesspress-anonymous-post" Plugin in wordpress.
code of "Front-form.php" is mentioned below:
<select name="' . $taxonomy . '_taxonomy" ' . $required . ' data-required-message="' . $category_required_message . '" >';
//$terms = get_terms( $taxonomy, array( 'hide_empty' => 0, 'order' => 'ASC', 'orderby' => 'id' ) );
/* Get all the pages of the KB */
$terms = get_posts('post_parent=142&post_type=page');
foreach ( $terms as $term ) {
//$form .='<option value="' . $term->term_id . '">' . $term->name . '</option>';
/* Adds child pages of KB as categories in dropdown */
if($post->post_parent == $term->ID)
{
$form .='<option value="' . $term->ID . '" selected>' . $term->post_title . '</option>';
}
else
{
$form .='<option value="' . $term->ID . '">' . $term->post_title . '</option>';
}
}
$form .='</select>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire