Support

Account

Forum Replies Created

  • Thanks @philby for the solution :). I can confirmed that code is working.

    Register code below:

    // register pricing table
    acf_register_block_type(array(
                   ...
                   ...
                   'render_template' => plugin_dir_path(__FILE__) . '/template-parts/blocks/pricing-table/pricing-table.php',
                   ...
                   ...
    ));
  • You can try to override the ACF settings for “enqueue_google_maps”=false for it to not load the script in the frontend. Also, I’ve added is_admin() check just to be sure that it only trigger the override on front-end.

    function my_acf_init() {
        if(is_admin()):
            return;
        endif;
        acf_update_setting('enqueue_google_maps', false);
    }
    
    add_action('acf/init', 'my_acf_init');
  • This code is not working, I’ve tried it and it’s returning an empty array. I’ve trace the code and found out that the filter code always returns false when using outside of ACF.

    Function
    $groups = acf_get_field_groups(array('post_type' => 'your-post-type'));

    Filter code

    function acf_match_location_rule( $rule, $screen ) {
    	
    	// vars
    	$result = false;
    	
    	
    	// filter
    	$result = apply_filters( "acf/location/rule_match/{$rule['param']}", $result, $rule, $screen );
    	$result = apply_filters( "acf/location/rule_match", $result, $rule, $screen );
    	
    	
    	// return
    	return $result;
    	
    }

    Hope someone can help further explore find a solution for this 🙂

  • I did try that code and its working fine on my part.

    CSS

    .acf-map {
        width: 100%;
        height: 400px;
        border: 1px solid #80d3f1;
        margin: 20px 0;
    }
    
    .acf-map .gmnoprint img {
        max-width: none; 
    }

    JS
    `jQuery(‘.acf-map’).each(function () {
    render_map($(this));
    });`

    HTML / PHP

    `function get_location_map($loc) {
    $str_ret =”;
    $str_ret .='<div class=”acf-map”>’;
    $str_ret .='<div class=”marker” data-lat=”‘.$loc[‘lat’].'” data-lng=”‘.$loc[‘lng’].'”></div>’;
    $str_ret .='</div>’;
    return $str_ret;
    }`

    $loc = will be your google map field.

    USE FUNCTION
    echo get_location_map(get_field('map'));

  • I am not sure if your using acf field or wp core because of as far as I know in order to get the value of the acf field you need to use get_field or get_sub_field(if repeater/flexible content).

    Then the above function/method “get_the_author_metat()” is a wordpress function. http://codex.wordpress.org/Function_Reference/get_the_author_meta

    And this code <?php echo wp_get_attachment_image( get_field( 'user_profile_image' ) ); ?> will gives you the whole image object with the correct url.

    Anyways happy for you to get it working.

  • I think your using the wrong function to get your acf field. the_author_meta() is a wordpress function.

    Can you try this.

    <?php echo wp_get_attachment_image( get_field( 'user_profile_image' ) ); ?>

  • Did you try to add a “support” attribute?

    ‘supports’ => array(‘thumbnail’)

    Hope I did help you.

  • I think you can add this code in your function.

    
    $location = get_field('location');
    
    if( !empty($location) ){
    echo '<div class="acf-map">
    	<div class="marker" data-lat="'.$location['lat'].'" data-lng="'.$location['lng'].'"></div>
    </div>';
    }

    Then with regards to your script and styles you can add it using wp_enqueue_script() a wordpress core function on adding css and js.

    Source for ACF Google Map: http://www.advancedcustomfields.com/resources/google-map/

    Source for WP Enqueue Script: http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    Thats it definitely you can display the map on the frontend.

  • Hi Moorewebx,

    I think you set your image field to return image ID. There’s two ways you can resolve your problem.

    1. Change return value to image url. See link screenshot for Image Field Settings.

    2. See code below:

    
    <?php echo wp_get_attachment_image( the_author_meta( 'user_profile_image' ) ); ?>

    Thats it, hope I did solve your problem.

  • Hi drs-nyc and elliot upon facing this problem I did come up some solution. Some one in the forum did suggest to use post.

    Here’s the code:

    function is_field_group_exists($value, $type='post_title') {
            $exists = false;
            if ($field_groups = get_posts(array('post_type'=>'acf-field-group'))) {
                foreach ($field_groups as $field_group) {
                    if ($field_group->$type == $value) {
                        $exists = true;
                    }
                }
            }
            return $exists;
        }
  • Thanks Daron it did give me an idea.

    Here what I come up with the idea.

    
    function is_field_group_exists($value, $type='post_title') {
            $exists = false;
            if ($field_groups = get_posts(array('post_type'=>'acf-field-group'))) {
                foreach ($field_groups as $field_group) {
                    if ($field_group->$type == $value) {
                        $exists = true;
                    }
                }
            }
            return $exists;
        }

    Anyone can use the function for checking if field group exist.

  • I have found this solution but it leads to another issue.

    Read code below

    class helper{
    //helper function
     public static function is_field_group_exists($value, $type='title') {
            $exists = false;
    
            if ($field_groups = acf_get_field_groups()) {
                foreach ($field_groups as $field_group) {
                    if ($field_group[$type] == $value) {
                        $exists = true;
                    }
                }
            }
            return $exists;
        }
    }
    
    //use
    if (!helper::is_field_group_exists('Field Group Title')) :
    // load acf exported php
            require_once (dirname(__FILE__) . '/includes/' . $acf_version . '/acf-field-group-exported.php');
        endif;
    

    Source: ACF5 field group exist

  • Thanks Elliot for the response. I did that for temporary fix. I did create new install wp in my local mamp and dump a sql for backup. Install acf4 and import all the xml files then upgrade/install acf5.

    Anyways just a wishlist much better if acf5 will be backward compatible with acf4 xml.

  • Hi Elliot & drs-nyc,

    I did try to use the acf_get_field_groups() function to check if the field group exist it did work fine and it will check if the field is existing or not, but it will cause register_field_group() function not to work or it will skip/it will not load the field group. Also I did try your suggestion to add the acf_disable_local() function still not working.

    Please see code below.

    
    class helper{
    //helper function
     public static function is_field_group_exists($value, $type='title') {
            $exists = false;
    
            if ($field_groups = acf_get_field_groups()) {
                foreach ($field_groups as $field_group) {
                    if ($field_group[$type] == $value) {
                        $exists = true;
                    }
                }
            }
            return $exists;
        }
    }
    
    //use
    if (!helper::is_field_group_exists('Field Group Title')) :
    // load acf exported php
            require_once (dirname(__FILE__) . '/includes/' . $acf_version . '/acf-field-group-exported.php');
        endif;
    
  • Thanks for sharing kartofelek007 will try that.

  • Hi Ben thanks for the quick response, the issue is that I already have acf5 install in a website and I need to add my old acf4 field groups which is saved as xml for my custom plugin.

    Hope Elliot will create an option to import xml for backward compatibility.

  • I did try the same thing inserting on nextgen gallery in wysiwyg acf field it works but in flexible content it doesn’t work.

    Sorry I did put it on the wrong wysiwyg built-in wp not the acf wysiwyg field, I did recheck an its doesn’t render the gallery.

    I think NextGen has custom code/tag to identify and render the gallery. Its not using a shortcode anymore. 🙁

    Hope to hear from you end.

    Thanks

  • hi elliot,

    Good day

    Also I am having problem rendering NextGen Gallery in wysiwyg editor. Please see code below.

    
     if (get_sub_field('column')) {
                            $row_count = count(get_sub_field('column'));
                            while (has_sub_field('column')) {
                                $str_ret .='<div class="item-wrapper">';
                                $str_ret .= '<h4 class="item-title">' . get_sub_field('title') . '</h4>';
                                
                                if(get_sub_field('type')=='content'){
                                    $content = get_sub_field('content');
                                }else{
                                    $p = get_sub_field('widget');
                                    $content = $p->post_content;
                                }
                                $str_ret .= '<div class="item-content">'.$content.'</div>';
                                $str_ret .='</div>';
                            }
                        }
    echo $str_ret;
    

    I am trying to create a multiple column content using flexible content wysiwyg editor but all I am getting is the one image. NextGen code will be like this <img alt="" src="http://domain.com.au/nextgen-attach_to_post/preview/id--3262" /> not same old shortcode.

    Hope to hear from your end.

    Thanks

Viewing 21 posts - 1 through 21 (of 21 total)