Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @kraudio

    It looks like the returned value is wrapped in another array. Your var_dump shows this in the first line: [0] => Array

    Can you test the unformatted value:

    <?php 
    
    echo '<pre>';
    	print_r( get_field('ac_imagem_destaque', false, false) );
    echo '</pre>';
    ?>
  • Quick question. Is this function only for adding ACF data to a GET request?

    I am trying to POST data from WP-API to ACF, but I’m struggling to find a way.

    Many thanks

  • Good morning, thanks for the help

    But not yet worked out, looks like the generated html
    <img src = "" alt = "" class = "thumb_285_350" height = "" width = "">

    What can it be?

  • 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'));

  • This reply has been marked as private.
  • By default images are returned as an array.

    You need to either change this to URL, or else you can pull the details from the array to get the URL, eg:

    
    <?php
    $image = get_field('ac_imagem_destaque');
    if( $image): 
       $alt = $image['alt'];		
       $thumb = $image['url'];
       $width = $image['width'];
       $height = $image['height'];
       ?>
    
       <img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" class="thumb_285_350" />
    										
    <?php endif; ?>
    

    You can read more here – http://www.advancedcustomfields.com/resources/image/

  • Just tried using:

    $field_key = "field_54289c0d8173b";
    $field = get_field_object($field_key);
    print_r($field);

    Where the key is the feature_image field.

    This resulted in an array output outside of the YARRP template, but in the template the variable was blank.

  • checking values

    <?php if( get_field('ac_imagem_destaque') ): ?>
    <?php print_r( get_field('ac_imagem_destaque') ); die; ?>
    <?php endif; ?>

    returning

    (
        [0] => Array
            (
                [ID] => 2062
                [id] => 2062
                [alt] => 
                [title] => destaque1a1
                [caption] => 
                [description] => 
                [mime_type] => image/jpeg
                [type] => image
                [url] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1.jpg
                [width] => 285
                [height] => 350
                [sizes] => Array
                    (
                        [thumbnail] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1-150x150.jpg
                        [thumbnail-width] => 150
                        [thumbnail-height] => 150
                        [medium] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1-244x300.jpg
                        [medium-width] => 244
                        [medium-height] => 300
                        [large] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1.jpg
                        [large-width] => 285
                        [large-height] => 350
                        [post-thumbnail] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1.jpg
                        [post-thumbnail-width] => 285
                        [post-thumbnail-height] => 350
                        [capa_thumb] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1.jpg
                        [capa_thumb-width] => 285
                        [capa_thumb-height] => 350
                        [capa_esquerda_thumb] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1-243x298.jpg
                        [capa_esquerda_thumb-width] => 243
                        [capa_esquerda_thumb-height] => 298
                        [galeria_thumb] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1.jpg
                        [galeria_thumb-width] => 285
                        [galeria_thumb-height] => 350
                        [acfimage] => http://acrio.com.br/wp-content/uploads/2014/10/destaque1a1.jpg
                        [acfimage-width] => 285
                        [acfimage-height] => 350
                    )
    
            )
    
    )
  • I figured it out. Here is my code…

    <section>
        <?php
    $args = array(
      'orderby' => 'name',
      'order' => 'ASC'
      );
    $categories = get_categories('child_of=39', $args);
      foreach($categories as $category) { ?>
        <div class="casino-games">
          <?php $image_url=get_field('featured_category_image', $category); ?>
          <a href="<?php get_category_link( $category->term_id ) ?>" title="<?php sprintf( __( "View all posts in %s" ), $category->name ) ?>" />
          <h3><?php echo $category->name ?></h3>
          <img src="<?php echo $image_url ?>" /> </a> </div>
        <?php } ?>
        <div class="clear"></div>
      </section>

    it was this part that did the trick for me…
    <?php $image_url=get_field('featured_category_image', $category); ?>

  • Hello, this solved my problem:

     
    <?php
    if( have_rows('repeater_field_name') )
    {
    	$field_key = "repeater_field_number";
    	$field = get_field_object($field_key);
    
    	foreach($field['value'] as $value)
    	{
    	if(!empty($value['repeater_subfield_name']))
    		{
    		$not_empty = true;
    		break;
    		}
    	}
    
    	if($not_empty == true)
    	{
    	echo '<h2>' . $field['label'] . '</h2>';
    	}
    
    	echo '<ul>';
    	while ( have_rows('repeater_field_name') )
    	{		 					
    	the_row();
    	$subfield = get_sub_field('repeater_subfield_name');
    				
    		if( !empty($subfield) )
    		{
    		echo '<li>' . $subfield . '</li>';
    		}
    	}
    	echo '</ul>';
    }
    ?>
    
  • WAIT !!!!

    1. acf_form_head() processing form after send it.
    2. IF your js error block your console before sent form you have still problem.

    try fix it that in your JS:

    acf.o = {};
    acf.screen = {};
    acf.o.post_id = 0;
    acf.screen.post_id = 0;

    Js console should by clear now. You could work in js and create fileuploader and gallery.

    Soon I’ll add code to frontend jquery uploader based on this library:
    http://blueimp.github.io/jQuery-File-Upload/

    Now I testing it.

  • Anyone who can help me with some examples??

    The most important question for now is:
    – just simply adjust the html and css (classes etc.) (override acf_form() ????)

    How to use the acf/load_field, acf/pre_save_post and acf/save_post.

  • Ok, finally got it sorted…
    For anyone else out there that might run into this problem here’s the solution.
    Just add the following to your functions.php file.

    
    //Include CPT In Categories Pages
    function namespace_add_custom_types( $query ) {
        if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
            $post_types = get_post_types( '', 'names' ); 
            $query->set( 'post_type', $post_types);
            return $query;
        }
    }
    add_filter( 'pre_get_posts', 'namespace_add_custom_types');
    
  • So none of those solutions worked but I did find something that did. I used the following code and was able to get the image to finally show up.

                                            <?php
    $publisher_photo = get_the_author_meta('user_profile_image');
    $image_src = wp_get_attachment_image_src($publisher_photo);
    echo '<img class="avatar" src="'. $image_src[0] .'" />';
    ?>

    Thank you for your help with this.

  • What is you change this

    [acf field="featured_category_image"

    to this

    [acf field="featured_category_image['url']"

    ? 🙂

  • I figured out my issue, in case this helps anyone. I used the sample code found here: http://www.advancedcustomfields.com/resources/google-map/ to generate a map. I grouped more than one using tabs (which uses jQuery UI’s tabs) and initiated it like so:

    $('.acf-map').each(function(){
        render_map( $(this) );
    });

    That left me with a map in each tab. The problem was, the hidden maps (in inactive tabs) didn’t fully render (only the top left block would be showing). There is likely a better way to do this, but I stored the javascript map variable so I could use it again, then listened for tab clicks so I could redraw the map like so:

    $( ".my-tabs" ).on( "tabsactivate", function( event, ui ) {
        var map = jQuery.data(document.body,"map");
        //resize the map    
        google.maps.event.trigger(map, 'resize');
        //center the map
        center_map( map );
    });

    This worked for me. I realize this isn’t an ACF “problem”, but it might be helpful to users to have it in the docs just in case they run into it.

    Cheers!
    Jay

  • Hi navid66

    when the example u have given, if i do <img src="<?php echo $first_img ?>"> that again results in
    <img src="">

    anything i’m doing wrong?

    regards!
    Mathieu

  • The first Woocommerce issue was likely unrelated to ACF Pro.

    The latter two popped up because acf_form_post::save_post() hooks onto ‘save_post’. This hook only fires if something changs on the post’s <i>main</i> fields. What this means, for example, if you change a field within an ACF metabox without changing anything else, this hook doesn’t fire. Instead, hook into ‘pre_update_post’. See this diff to solve this problem:
    http://pastie.org/9617141
    Here is a reference to this same problem in another plugin.

  • Ohhh array_merge() and array_unique(), of course. Here I am looking for WordPress / ACF functions to do the job when vanilla php functions were the answer.

    Thank you so much, that solved the problem perfectly.

  • Problem fixed. For anyone who may run into this problem, make sure that queries are ended properly.

  • 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.

  • I did have the return value for image. I also tried your code but am still only getting it to output the image ID. http://s15.postimg.org/q2ycawbwb/Capture.jpg

  • Actually yes, but I had to check the database to see how a normal google map mark was being saved, because the google map mark is an array with the address, the latitude and the longitude, so I had to create the array and then send it to the custom field with update_post_meta

    $coordinates = getCoordinates($fullAddress);
            $coordinates = explode(",", $coordinates);
    
            $latitude = $coordinates[0];
            $longitude = $coordinates[1];
    
            $google_map_mark = array();
            array_push($google_map_mark, "address");
            array_push($google_map_mark, $fullAddress);
            array_push($google_map_mark, "lat");
            array_push($google_map_mark, $latitude);
            array_push($google_map_mark, "lng");
            array_push($google_map_mark, $longitude);
    
            $value = array("address" => $fullAddress, "lat" => $latitude, "lng" => $longitude);
    
    update_post_meta($post_id, 'coordinates', $value);
  • Hi @stiand

    Thanks for the info, Are you able to check your console log an look for:
    1. any JS errors when clicking the edit button in question
    2. the json response from an ajax call when clicking the edit button.

    Thanks
    E

  • 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

Viewing 25 results - 17,751 through 17,775 (of 21,364 total)