So far I am using this but not having any succes.
function mytank_custom_store_category_image( $store_meta, $store_id ) {
if ( function_exists( 'z_taxonomy_image_url' ) ) {
$terms = wp_get_post_terms( $store_id, 'wpsl_store_category' );
if ( $terms ) {
if ( !is_wp_error( $terms ) ) {
if ( isset( $_GET['filter'] ) && $_GET['filter'] ) {
$filter_ids = explode( ',', $_GET['filter'] );
foreach ( $terms as $term ) {
//only return terms whose parent is Fuel Stations (ID)
if ($term->parent == 12){
if ( in_array( $term->term_id, $filter_ids ) ) {
$cat_marker = z_taxonomy_image_url( $term->term_id );
if ( $cat_marker ) {
$store_meta['categoryMarkerUrl'] = $cat_marker;
}
}
}
}
} else {
$store_meta['categoryMarkerUrl'] = z_taxonomy_image_url( $terms[0]->term_id );
}
}
}
}
return $store_meta;
}
]]>Can someone help me?
Thanks
]]>I do not understand how to modify the following code with my category and my custom pointer. Let’s say the pointer is located in /wp-content/pointer/specialpointer.png and the category name is “mycategory”
Category images plugin is already installed and working.
How do i modify the following code? And will be this enough? Thanks to everybody will help me in this!
add_filter( 'wpsl_cpt_info_window_meta_fields', 'custom_cpt_info_window_meta_fields', 10, 2 );
function custom_cpt_info_window_meta_fields( $meta_fields, $store_id ) {
$terms = wp_get_post_terms( $store_id, 'wpsl_store_category' );
if ( $terms ) {
if ( !is_wp_error( $terms ) ) {
if ( function_exists( 'z_taxonomy_image_url' ) ) {
$meta_fields['categoryMarkerUrl'] = z_taxonomy_image_url( $terms[0]->term_id );
}
}
}
return $meta_fields;
}
]]>I have used this method https://wpstorelocator.co/document/use-custom-markers/ to change marker image.
But it’s showing in backend but not showing in front-end. Can you please help?
]]>Any Ideas?
]]>First add the wpsl_meta_box_fields and wpsl_frontend_meta_fields filters to your child theme. Documentation for both here https://wpstorelocator.co/document/wpsl_meta_box_fields/ and here https://wpstorelocator.co/document/wpsl_frontend_meta_fields/.
add_filter('wpsl_meta_box_fields', 'custom_meta_box_fields'); function custom_meta_box_fields($meta_fields) { $meta_fields[__( 'Additional Information', 'wpsl' )] = array( 'phone' => array( 'label' => __( 'Tel', 'wpsl' ) ), 'fax' => array( 'label' => __( 'Fax', 'wpsl' ) ), 'email' => array( 'label' => __( 'Email', 'wpsl' ) ), 'url' => array( 'label' => __( 'Url', 'wpsl' ) ), 'alternate_marker_url' => array( 'label' => __( 'Alternate Marker Url', 'wpsl' ) ) ); return $meta_fields; } add_filter('wpsl_frontend_meta_fields', 'custom_frontend_meta_fields'); function custom_frontend_meta_fields($store_fields) { $store_fields['wpsl_alternate_marker_url'] = array( 'name' => 'alternate_marker_url', 'type' => 'url' ); return $store_fields; }
Now in Edit Store > Additional Information you will have another field “Alternate Marker Url” available. Put the absolute url of the custom pin/marker here.
Now we need to modify a little plugin code directly. We need to make it load the non minified wpsl-gmap.js script (you can minify after if you like). In wp-store-locator/frontend/class-frontend.php find the following (should be line 1664 in the latest version):
wp_enqueue_script( 'wpsl-js', WPSL_URL . 'js/wpsl-gmap'. $min .'.js', array( 'jquery' ), WPSL_VERSION_NUM, true );
Change this to:
wp_enqueue_script( 'wpsl-js', WPSL_URL . 'js/wpsl-gmap.js', array( 'jquery' ), WPSL_VERSION_NUM, true );
And finally in wp-store-locator/js/wpsl-gmap.js we need to make it set the marker url to the url specified if it was set. Find the addMarker function and add the following if block before mapIcon is initialized:
if(infoWindowData.alternate_marker_url) { url = infoWindowData.alternate_marker_url; }
Here’s the section with the block added:
... if ( storeId === 0 ) { infoWindowData = { store: wpslLabels.startPoint }; url = markerSettings.url + wpslSettings.startMarker; } else { url = markerSettings.url + wpslSettings.storeMarker; } if(infoWindowData.alternate_marker_url) { url = infoWindowData.alternate_marker_url; } mapIcon = { url: url, scaledSize: new google.maps.Size( Number( markerSettings.scaledSize[0] ), Number( markerSettings.scaledSize[1] ) ), //retina format origin: new google.maps.Point( Number( markerSettings.origin[0] ), Number( markerSettings.origin[1] ) ), anchor: new google.maps.Point( Number( markerSettings.anchor[0] ), Number( markerSettings.anchor[1] ) ) }; ...
Hope this helps
]]>From you instructions from a year ago…it appears changes need to be made in the wpsl.gmap.js file, but I can’t find “markerPath
Has this code changed?
https://www.ads-software.com/plugins/wp-store-locator/
]]>