Home › Forums › MapPress Support › more custom fileds in Geocoding body field
Tagged: custom fields, geocoding
- This topic has 9 replies, 2 voices, and was last updated 9 years ago by
Chris.
-
AuthorPosts
-
January 7, 2014 at 9:39 pm #14033
Hello,
this plugin is awesome! Is it possible to have more custom fileds in Geocoding body field ?Thank you
January 8, 2014 at 5:50 am #14036Hi, the body is just a single field, but if you want to display other custom fields in the infowindow you can modify the POI display template file ‘map_poi.php’. See the documentation for some info about modifying templates.
Here’s an example to print a custom field for mashups or single maps:
<?php global $post; $postid = ($poi->postid) ? $poi->postid : $post->ID; echo get_post_meta($postid, 'my_field_name', true); ?>
January 8, 2014 at 7:26 am #14040Hello,
thank you for your answer. i tried this solution but it is not working with automatically generated maps from CF – in the info window custom field insert via code in template map_poi.php doesn’t display.January 8, 2014 at 8:02 am #14041Hi,
Perhaps there is a syntax error? Below is a template file that will display field ‘test’ just below the POI body.
If that doesn’t work for you, please provide your template file and let me know if you’re displaying a map or mashup, along with any other details that might help.
<div class='mapp-iw'> <div class='mapp-title'> <?php echo $poi->get_title_link(); ?> </div> <div class='mapp-body'> <?php echo $poi->get_thumbnail(array('class' => 'mapp-thumb')); ?> <?php echo $poi->get_body(); ?> <?php global $post; $postid = ($poi->postid) ? $poi->postid : $post->ID; echo get_post_meta($postid, 'test', true); ?> </div> <div class='mapp-links'> <?php echo $poi->get_links(); ?> </div> </div>
January 10, 2014 at 2:18 am #14055Hello,
i modified template map_poi.php file and it’s working for mashups but not for single map. Single map in single post is generated automatically from geocodes = custom fields with street address and city, but special custom field which i added into template file is not displayed. Can you help me with this issue?Thanks a lot
January 13, 2014 at 1:34 am #14069Hi,
Check that the special field is actually populated in the post you’re displaying. You should be able to see it in the WordPress post editor unless it is hidden (i.e. starts with ‘_’). If it’s hidden, check database table wp_postmeta for that post.
Then, modify map_poi.php with some ‘echo’ statements to see what’s going on:
<?php global $post; $postid = ($poi->postid) ? $poi->postid : $post->ID; echo "The post is: $post->ID and the field is: "; echo get_post_meta($postid, 'test', true); ?>
If the above steps don’t help, please send me a login and I’ll see if I can find the issue for you. Please provide a post I can test with this special field.
January 29, 2014 at 7:51 pm #14154Hello,
sorry for the late answer but i have been out of business.
So i tried some echo statements and the result is:in mashup it’s ok:
http://www.rkzl-tt.sk/lekarcat/piestany/
(The post is: and the field is: 921 01 Piešťany)in single post (custom post type) not:
http://www.rkzl-tt.sk/lekar/jurga-daniel/
(The post is: 1226 and the field is:_________)i am using advanced custom fields plugin so code is:
<?php
global $post;
$postid = ($poi->postid) ? $poi->postid : $post->ID;
echo “The post is: $post->ID and the field is: “;
echo get_field(‘mesto’, $postid);
?>Can you check it please?
Thank a lot
January 30, 2014 at 6:00 am #14157Hi,
If you use a regular (non-ACF) field with the code I gave you, does it work?
That code works for me on my test system, so I think the problem is with getting the ACF field value using get_field().
Try to test this without MapPress. Add your code with get_field() into the template file for single posts (usually in the theme directory ‘single.php’). Do you see a value that way?
If not, then you’ll need to ask the ACF folks why the value isn’t coming through.
January 30, 2014 at 7:44 pm #14160Hello,
i use that custom field in single template and there’s ok.
( http://www.rkzl-tt.sk/lekar/jurga-daniel/ ) – all description is from ACF and is displayed correctly.Do you have any idea?
Thank you for your support.
January 31, 2014 at 6:59 am #14162Hi,
I’m sorry, but I don’t know why the ACF call wouldn’t work. The POI layout runs within that same template, so it should behave identically to a call from the template.
Does it work if you use a regular (non-ACF) custom field? Perhaps you can have ACF save the value to a custom field you can read with get_post_meta() instead.
Also, could you post your entire template file or email it to me?
-
AuthorPosts
- You must be logged in to reply to this topic.