For a Wordpress plugin that I am currently developing (support ticket system) I have to map the following.
Each ticket is assigned to a project (1: 1 relationship).
Each project is in turn assigned to a customer (1: 1 relationship).
Thus, a customer can be assigned any number of projects (1: n relationship).
Also a Ticket could have multiple answers (like this question) which I think should also be a cpt.
I have already created the ticket as a custom post type.
Customers and project should be in my opinion taxonomies of the ticket.
The project should be assigned to the customer as parent taxonomy.
Therefore, I have set hierarchical = true for project.
But actually projects will be shown instead of customers in the parent dropdown(see screenshot below).
As far as I've read in Codex, I can customize the dropdown using the "taxonomy_parent_dropdown_args"-hook.
But I am not sure if there might be problems due to the different slugs.
Is this correct or is there a better way to archieve this?
Try it
$taxonomyName = "com_category";
$parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'slug', 'hide_empty' => false));
foreach ($parent_terms as $pterm) {
$terms = get_terms($taxonomyName, array('parent' => $pterm->term_id, 'orderby' => 'slug', 'hide_empty' => false));
foreach ($terms as $term) {
echo '<div class="single_cat col-md-3">';
echo '<h3>'.$pterm->name.'</h3>';
echo "<ul>";
echo '<li><a href="' . get_term_link( $term->name, $taxonomyName ) . '">' . $term->name . '</a></li>';
echo "</ul>";
echo '</div>';
}
}