Ive been asked to create a new dropdown menu in wordpress. I have never used word press and i have also never coded in php before. I've managed to find a piece of code for an existing dropdown menu but i do not understand how it works. i was hoping someone could help explain it to me so i can get an understanding of what is going on.
<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
<tr class="form-field term-parent-wrap">
<th scope="row"><label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label></th>
<td>
<?php
$dropdown_args = array(
'hide_empty' => 0,
'hide_if_empty' => false,
'taxonomy' => $taxonomy,
'name' => 'parent',
'orderby' => 'name',
'selected' => $tag->parent,
'exclude_tree' => $tag->term_id,
'hierarchical' => true,
'show_option_none' => __( 'None' ),
);
/** This filter is documented in wp-admin/edit-tags.php */
$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
wp_dropdown_categories( $dropdown_args ); ?>
<?php if ( 'category' == $taxonomy ) : ?>
<p class="description"><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p>
<?php endif; ?>
</td>
</tr>
Thanks
Firstly, tell us what kind of dropdown you're looking for. WHat do you want to have inside the dropdown menu? As your code is currently set to show category links to your posts.
This might be more useful, if you read the Wordpress codex about this function, and look through your code to try and follow it.
You can also try changing the arguments to change the output of the dropdown.
https://codex.wordpress.org/Function_Reference/wp_dropdown_categories