Hello, I'm having problems displaying a map created with the plugin pronamic google maps from a child post.
I have a type of parent post named "lugar" (created with types) with five fields: four of them created with wp-types and one of them created with Pronamic Google Maps. When I try to display all the fields from this parent post in a child post I can do it with fields "lugar", "direccion", "comuna" and "web" (all of them fields created with types) but not in the case of the map, using the same logic than for the other fields.
This is the code
<?php echo types_render_field("lugar", array('style' => 'text',"post_id"=>'$lugar')) ?>
<?php echo types_render_field("direccion", array('style' => 'text',"post_id"=>'$lugar'));?>
<?php echo types_render_field("comuna", array('style' => 'text',"post_id"=>'$lugar'));?> <
<?php echo types_render_field("web", array('style' => 'text',"post_id"=>'$lugar'));?>
<?php
if ( function_exists( 'pronamic_google_maps' ) ) {
pronamic_google_maps(
array('width' => '100%', 'height' => 200, "post_id"=>'$lugar) );
}
?>
Another question in the same code is, how can I convert one of the fields in a link to the parent post?
Thanks in advance
That's because in Types we accept "$post_type_slug" as argument to render a field. But this plugin you are using doesn't (pronamic google maps). So this is not a problem with Types, but with pronamic google maps. There is not we can do. I would recommend you to contact the author of this plugin.
Please let me know if you are satisfied with my answer and if I can help you with any other related question.
Thanks for your reply, Adriano
How you said that it is not possible do this with pronamic plugin, I was trying to create a google map in a type of posts following the instructions in https://toolset.com/documentation/user-guides/map-wordpress-posts/. But I can't get show a single map.
I show you the code in the content template:
Content:
[types field="direccion" show_name="true" ] [/types]
[types field="comuna" show_name="true"][/types]
[types field="web" target="_blank" show_name="true"][/types]
<div id="js-map-element" data-marker-title='[wpv-post-title]' data-marker-lat='[types field="latitud"][/types]' data-marker-lon='[types field="longitud"][/types]'>
[wpv-view name="eventosxlugar"]
JS
jQuery( document ).ready(function($) {
$("#js-main-map-canvas").wpvmap({
mapType : google.maps.MapTypeId.TERRAIN
});
});
And the maps is not displaying... What i'm doing wrong?
Thanks a lot!
I need to request temporary access (wp-admin and FTP) to your site - preferably to a test site where the problem has been replicated if possible - in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.
Thanks Adriano,
The content template when I'm trying to display the map created with types is in "Lugar"
I can not log there, getting the following fatal error:
Fatal error: Cannot redeclare mysql2date() (previously declared in /xxx/wp-includes/functions.php:26) in /xxx/wp-content/themes/bucket-child/functions.php on line 42
Please fix that and let me know when I can look to it.
Excuse me, Adriano. Today I had some problems with the web. But now is working again
I've fixed your Content Template, but there is a conflict in your website. If you look the JS console bar (attached image), you will notice the Google maps is being called twice. You must fix that to make it works.
Hello, Adriano
I'm doing tests with the code you wrote in a different domain with other theme (which doesn't have google maps incorporated and without other google maps plugin installated) and the map doesn't display again. This is the link: hidden link
Thanks in advance
The map was there but hidden. So, I've just defined a fixed height to the DIV's map and it worked:
#js-main-map-canvas{
height: 260px;
}
Please let me know if you are satisfied with my answer and if I can help you with any other related question.
Thank you very much, Adriano
It works perfectly. In the post and in a child post too.
Excellent plugin and support!