I had an almost working solution that is basically this code:
in the functions.php of the child theme:
function implement_ajax() {
if(isset($_POST['main_catid']))
{
$categories= get_categories('child_of='.$_POST['main_catid'].'&hide_empty=0');
foreach ($categories as $cat) {
$option .= '<option value="'.$cat->term_id.'">';
$option .= $cat->cat_name;
$option .= ' ('.$cat->category_count.')';
$option .= '</option>';
}
echo '<option value="-1" selected="selected">Sub Categories</option>'.$option;
die();
} // end if
}
add_action('wp_ajax_my_special_ajax_call', 'implement_ajax');
add_action('wp_ajax_nopriv_my_special_ajax_call', 'implement_ajax');//for users that are not logged in.
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}
For the job-submit.php template I added the following
<script type="text/javascript">
$(function(){
$('#main_cat').change(function(){
var $mainCat=$('#main_cat').val();
// call ajax
$("#sub_cat").empty();
$.ajax({
url:"<?php bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php",
type:'POST',
data:'action=my_special_ajax_call&main_catid=' + $mainCat,
success:function(results)
{
// alert(results);
$("#sub_cat").removeAttr("disabled");
$("#sub_cat").append(results);
}
});
}
);
});
</script>
wp_dropdown_categories('show_count=0&selected=-1&hierarchical=1&depth=1&hide_empty=0&exclude=1&show_option_none=Main Categories&name=main_cat');
?>
This got us a start but now we have made some changes that look like this.
$category_args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
'fields' => 'id=>name',
);
$category_args1 = $category_args;
$category_args1['parent'] = 0;
$job_categories1 = get_terms('job_listing_category', $category_args1);
$fields['job']['_job_cat1'] = array(
'label' => __( 'Cat1', 'wp-job-manager' ),
'type' => 'select',
'options' => $job_categories1,
'required' => true,
'placeholder' => '',
'priority' => 3.1,
);
$category_args2 = $category_args;
/*$category_args2['parent'] = 1;*/
$job_categories2 = get_terms('job_listing_category', $category_args2);
$fields['job']['_job_cat2'] = array(
'label' => __( 'Cat2', 'wp-job-manager' ),
'type' => 'select',
'options' => $job_categories2,
'required' => true,
'placeholder' => '',
'priority' => 3.2,
);
$category_args3 = $category_args;
/*$category_args3['parent'] = 2;*/
$job_categories3 = get_terms('job_listing_category', $category_args3);
$fields['job']['_job_cat3'] = array(
'label' => __( 'Cat3', 'wp-job-manager' ),
'type' => 'select',
'options' => $job_categories3,
'required' => true,
'placeholder' => '',
'priority' => 3.3,
);
return $fields;
}
/*
wp_dropdown_categories('show_count=0&selected=-1&hierarchical=1&depth=1&hide_empty=0&exclude=1&show_option_none=Main Categories&name=main_cat&taxonomy=job_listing_category');
*/
function implement_ajax() {
if(isset($_POST['main_catid']))
{
$categories= get_categories('child_of='.$_POST['main_catid'].'&hide_empty=0&taxonomy=job_listing_category');
foreach ($categories as $cat) {
$option .= '<option value="'.$cat->term_id.'">';
$option .= $cat->cat_name;
$option .= ' ('.$cat->category_count.')';
$option .= '</option>';
}
echo '<option value="-1" selected="selected">Sub Categories</option>'.$option;
die();
} // end if
}
add_action('wp_ajax_my_special_ajax_call', 'implement_ajax');
//add_action('wp_ajax_nopriv_my_special_ajax_call', 'implement_ajax');//for users that are not logged in.
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}
// Add our own function to filter the fields
add_filter( 'submit_resume_form_fields', 'custom_submit_resume_form_fields' );
I am kind of lost by these changes but if you can guide me in a good direction I would appreciate it. Also if you just know of someone we can hire to do this right we are willing to go that rout. I posted in the wordpress job section but got so many low quality responses I have not been able to effectivly sort through them all.