Plugin Author
hupe13
(@hupe13)
Sorry, I don’t know ACF.
Raruto, the author of leaflet-elevation, which I’m using, has an example. Is this what you want?
Thanks for your answer.
Yes, I know raruto, it works fine.
Since yesterday, I changed some things on my website.
I added code in function.php. Now :
1) GPX file is added in each article as a custom field with ACF.
2) I can include ACF file field adress automatically in a specific generated shortcode, using WP-GPX-Maps.
But I just have a problem, shortcode, added in a widget zone (using shortcode widget), is shown as text, and I can’t see map.
For example, I can see [sgpx gpx=”/wp-content/uploads/gpx/00_gtm_integral.gpx”], but not the map itself. 🙁
Plugin Author
hupe13
(@hupe13)
Which shortcode you are mean: elevation or sgpx? sgpx is from WP GPX Maps.
Extensions for Leaflet Map has an option to migrate, but there is a bug in the actual version. I just updated the Github version.
But it is better to use elevation as long as Bastianon does not update WP GPX Maps.
I tried both of them.
SGPX shortcode seems to work on my website, elevation shortcode too (I tried both of them).
My actual problem :
This code create a shortcode, showing AGGPX shortcode with ACF file name :
// Get the GPX URL and tranform into a valid shortcode for the 'WP-GPX-Maps' plugin
function transform_GPX_URL_into_shortcode() {
global $post;
// Get URL from ACF 'fichier_gpx' field
$url = get_field('fichier_gpx', $post->ID)['url'];
// Keep only the folder name, without the domain
$url = substr($url,strpos($url,'/wp-content'));
// Add info to create the shortcode and return the url string
return $url = '[sgpx gpx="' . $url . '"]';
}
add_shortcode('carte','transform_GPX_URL_into_shortcode');
But when I add [carte] in a shortcode widget, it writes (perfectly !) AGGPX shortcode text, but don’t show the map.
I don’t know why… 🙁
-
This reply was modified 3 years, 9 months ago by
chaosad2.
-
This reply was modified 3 years, 9 months ago by
chaosad2.
Plugin Author
hupe13
(@hupe13)
Try return $url = do_shortcode('[sgpx gpx="' . $url . '"]');
Sorry, it doesn’t work :
Parse error: syntax error, unexpected ‘&’ in /homepages/38/d224481250/htdocs/trackserver/wp-content/themes/bam-theme-enfant-creation-new-slang-1660112514/functions.php on line 71
It seems to be the first “&”, just after “do_shortcode(“.
Plugin Author
hupe13
(@hupe13)
$my_shortcode = '[sgpx gpx="' . $url . '"]';
return do_shortcode($my_shortcode);
Hi,
Sorry, I didn’t see your answer.
Thanks, it works perfectly !
Plugin Author
hupe13
(@hupe13)
Extensions for Leaflet Map has an option to migrate, but there is a bug in the actual version. I just updated the Github version.
The bug is fixed now.
I am glad that I could help.