more custom fileds in Geocoding body field

Home Forums MapPress Support more custom fileds in Geocoding body field

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #14033
    tomas.halo
    Participant

    Hello,
    this plugin is awesome! Is it possible to have more custom fileds in Geocoding body field ?

    Thank you

    #14036
    Chris
    Keymaster

    Hi, 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); 
    ?>
    #14040
    tomas.halo
    Participant

    Hello,
    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.

    #14041
    Chris
    Keymaster

    Hi,

    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>
    
    #14055
    tomas.halo
    Participant

    Hello,
    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

    #14069
    Chris
    Keymaster

    Hi,

    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.

    #14154
    tomas.halo
    Participant

    Hello,
    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

    #14157
    Chris
    Keymaster

    Hi,

    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.

    #14160
    tomas.halo
    Participant

    Hello,

    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.

    #14162
    Chris
    Keymaster

    Hi,

    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?

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.