I have added Custom Post Fields (a list of check-boxes) to the Custom Taxonomy ‘product_cat’.
Also I have a drop-down with this Custom Taxtonimies (‘product_cat’) on my Custom Post Type (‘product’) Add/Edit page.
How I can get a metadata from these Custom Fields with using jQuery when the Custom Taxonomy drop-down was changed?
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#prodcatoptions').change(function() {
var productsubcut = jQuery('#prodcatoptions').val();
if ( productsubcut == '') {
} else {
var data = {
/* I don't know what I need to type here */
};
jQuery.post(ajaxurl, data, function(response){
console.log(response);
});
}
});
});
</script>
In order to do that, you will have to issue an ajax request to the wordpress backend. For example:
In the backend you will have the following function in your functions.php file
This will return the metadata about the selected taxonomy.
Change your javascript as follows: