Hi,
hmm i would need some more details. Do you have the DTD snippet configured to work with advert_location taxonomy (instead of the advert_category taxonomy)?
Also is it possible for you to paste here a link to the page where you are having this problem so i can take a look at it?
Finally, a screen with your settings in Maps and Locations would be very useful, thanks.
Thread Starter
zacsto
(@zacsto)
At the end of the DTD snippet is has the following code which I thought was adding in the advert_location functionality. I also tried swapping out all the advert_category for adverts_location but it broke the DTD plugin. FYI, I’m not a web developer but more a change something and see what happens.
add_filter( "adverts_form_load", function( $form ) {
if( $form["name"] != "advert" ) {
return $form;
}
foreach( $form["field"] as $key => $field ) {
if( $field["name"] === "adverts_location" ) {
$form["field"][$key]["type"] = "adverts_field_select_dependant";
$form["field"][$key]["options_callback"] = null;
$form["field"][$key]["options"] = array();
$form["field"][$key]["dtd_use_taxonomy"] = "advert_location";
}
}
return $form;
}, 9000 );
The problems I’m having are both in the frontend area and in the admin area. I’d be happy to give you an admin account but I’d rather not post it on the open web if there’s another way to send it to you…
Screenshot of the Add Listing Page showing dropdown working
View post on imgur.com
Screenshot of Preview Listing showing numbers for location
View post on imgur.com
Screenshot of admin area showing loading symbol
View post on imgur.com
Screenshot of DTD off and Location showing correctly
View post on imgur.com
I’ve tried all MAL settings but here’s the one that makes the most sense to me.
View post on imgur.com
To make this snippet work with advert_location taxonomy you would additionally need to add in your theme functions.php file the code below
###############
add_action( "save_post_advert", "my_mal_save_advert", 10, 3 );
function my_mal_save_advert( $post_ID, $post, $update ) {
if( !isset( $_POST ) || empty( $_POST ) ) {
return;
}
if( isset( $_POST['adverts_location'] ) ) {
if( ! empty( $_POST['adverts_location'] ) ) {
$location = array( intval( $_POST['adverts_location'] ) );
} else {
$location = null;
}
wp_set_post_terms( $post_ID, $location, 'advert_location' );
}
}
add_action( "admin_footer", function() {
?>
<script type="text/javascript">
if( typeof adverts_frontend_lang === 'undefined' ) {
var adverts_frontend_lang = { ajaxurl: '<?php echo admin_url( 'admin-ajax.php' ) ?>' };
}
</script>
<?php
});
Also in dependant-taxonomy-dropdown.php replace line 75 that is
if( isset( $field["value"][0] ) ) {
replace with
if( is_array( $field["value"] ) && isset( $field["value"][0] ) ) {
Finally, in MAL settings in field ‘Location Field’ select ‘Dropdown filed with Location taxonomy.’
Thread Starter
zacsto
(@zacsto)
Thank you very much! Everything is working great now!