Support

Account

Forum Replies Created

  • @paul115
    on the email template, you need to get the order ID first, like:

    
    <?php
    $order_id = $order->id; 
    //then
    $section 	= get_field( 'location_section', $order_id );
    $column 	= get_field( 'location_column', $order_id );
    $row 		= get_field( 'location_row', $order_id );
    ?>
    <p>Location of item is: <strong>S<?php echo $section; ?>-C<?php echo $column; ?>-R<?php echo $row; ?></strong></p>
    
  • To get the featured image from relationship, you need to use:

    <?php $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'medium_large'); ?>

    This will grab the featured image URL from the ID, once you have the url, you can use it in img src or as an background.

    Hope this helps.

  • Thank you John, that solved it.

  • <?php if( have_rows('gallery-repeater') ): ?>
    
       <!-- CHECK TO SEE IF IT HAS ROWS IN IT -->
       <?php while ( have_rows('gallery-repeater') ) : the_row(); ?>
    
         <!-- DISPLAY THE TEXT-FIELD THEN ASSIGN OUR GALLERY TO VARIABLE $images -->
         <?php the_sub_field('gallery-name'); 
    
         $images = get_sub_field('gallery-images'); 
    
         if( $images ):?>
            <?php foreach( $images as $image ): ?>
    	   <a href="<?php echo $image['url']; ?>">
    	      <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
               </a>
               <p><?php echo $image['caption']; ?></p>
            <?php endforeach; ?>
         <?php endif; 
       endwhile;
    else :
    // no rows found
    endif; ?>

    src: https://support.advancedcustomfields.com/forums/topic/gallery-field-inside-a-repeater-field/

  • add_shortcode( 'qg_shortcode', 'qg_shortcode' );
    function qg_shortcode() {
        $buffer = '<h3>Post Titles</h3>';
        $q = new WP_Query(array(
            'post_type' => 'post',
            'posts_per_page' => 5
        ));
        while ($q->have_posts()) {
            $q->the_post();
            $buffer = $buffer.get_the_title().'<br>';
        }
        wp_reset_postdata();
        return $buffer;
    }
  • [acf field="field_name" post_id="123"]

    Example:
    This is a story about a boy named [acf field="name"]. He is [acf field="age"] years old.

    src: https://www.advancedcustomfields.com/resources/shortcode/

  • For forms, its better to use Gravity forms or Contact form 7(Free Plugin).

  • 
     <?php
    $field = get_field('equipement');
    if( $field ): ?>
    <ul>
    	<?php foreach( $field as $value ): ?>
    		<li class="<?php echo $value; ?>"><?php echo $value; ?></li>
    	<?php endforeach; ?>
    </ul>
    <?php endif; ?>
    
  • For me, I have done like this and it kinda worked for me.
    On Function center_map, if you are using more than 1 marker then on else section add

    map.setCenter( bounds.getCenter() );
    		map.setZoom( 4 );
    /* center_map */
    function center_map( map ) {
    	// vars
    	var bounds = new google.maps.LatLngBounds();
    	// loop through all markers and create bounds
    	$.each( map.markers, function( i, marker ){
    		var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
    		bounds.extend( latlng );
    	});
    	// only 1 marker?
    	if( map.markers.length == 1 )
    	{
    		// set center of map
    	    map.setCenter( bounds.getCenter() );
    	    map.setZoom( 4 );
    	}
    	else
    	{
    		// fit to bounds
    		//map.fitBounds( bounds );
    		map.setCenter( bounds.getCenter() );
    		map.setZoom( 4 );
    
    	}
    }
  • Hi James
    In this case, how shall we hide that tab or remove that tab if get_field('fieldname', $post_id); is empty.

    Sorry to bother you, I found the solution:

    //adding new tab//
    add_filter( 'woocommerce_product_tabs', 'product_tab' );
    function product_tab( $tabs ) {
    if ( get_field('fieldname', $post_id) ) {
    $tabs[] = array(
    'title' => 'Specifications',
    'priority' => 15,
    'callback' => 'show_content'
    );
    }
    return $tabs;
    }
    function show_content() {
    $downloads = get_field('fieldname', $post_id);
    if( $downloads ):
    echo get_field('fieldname', $post_id);
    endif;
    }

  • Hi James,
    My friend helped me out in this, removed all ACF map code and put this one, and it worked like a charm.

    <script>
    function createMap(id){
    	var Element = $("#" + id);
    	if (Element.find(".marker").length != 1){
    		return;
    	}
    	var latlng = new google.maps.LatLng(Element.find(".marker").data("lat"), Element.find(".marker").data("lng"));
    	var myOptions = {
    			zoom: 16,
    			center: latlng,
    			mapTypeId: google.maps.MapTypeId.ROADMAP,
    			disableDefaultUI: true,
    			mapTypeControl: false,
    			zoomControl: true,
    			scrollwheel: false,
    			zoomControlOptions: {
    					style: google.maps.ZoomControlStyle.SMALL
    			}
    	};
    
    	var map = new google.maps.Map(Element[0], myOptions);
    	console.log("Creating map at " + Element.attr('id'));
    
    	var marker = new google.maps.Marker({
    			icon: "<?php bloginfo('template_url'); ?>/img/custom_marker.png",
    			position: latlng,
    			map: map
    	});
    	return {map: map, marker: marker};
    }
    
    var $ = jQuery;
    	$('.panel-collapse.collapse').parent().find(".panel-title a").click(function(){
    		//console.log($(this).parent().parent().parent().find(".acf-map").attr('id'));
    		var result = createMap($(this).parent().parent().parent().find(".acf-map").attr('id'));
    		if (result != null){
    			google.maps.event.addListenerOnce(result.map, 'idle', function(){
    				google.maps.event.trigger(result.map, 'resize');
    				result.map.setCenter(result.marker.getPosition());
    			});
    		}
    	});
    
    	//Run create map on the first map - because it is already visible
    	createMap($(".acf-map").attr("id"));
    </script>
  • This reply has been marked as private.
  • I must be dumb, i couldn’t figure out the right code. ๐Ÿ™

  • Hey I am using bootstrap 3 collapse, I still have the problem, the first map loads but other maps are not loading properly. Can you please help me out where I am wrong ?

  • Thank you Thomask, It worked for me.

  • Hi Jonathan
    I have solved this, I am loving this ACF.

    <ul class="nav nav-tabs" role="tablist">
      <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
      <?php if ( have_rows('repeater', 'option') ) {
    	while ( have_rows('repeater', 'option') ) : the_row(); 
    	$image = get_sub_field('repeater_subfield1', 'option' );
    	endwhile; 
    	if($image) {
    	?>
    	<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
    	<?php }  } ?>
      </ul>
    
    <!-- Tab panes -->
    <div class="tab-content">
      <div role="tabpanel" class="tab-pane active" id="home">Home Text</div>
      <div role="tabpanel" class="tab-pane" id="profile">
        <?php  while ( have_rows('repeater', 'option') ) : the_row(); ?>
        <div class="col-sm-2 col-xs-6 color_showcase text-center"> 
        	<img src="<?php the_sub_field('repeater_subfield1'); ?>" alt=""> 
          	<?php the_sub_field('repeater_subfield2'); ?>
        </div>
        <?php endwhile;  ?>
        </div>
    </div>
  • Hi Jonathan

    I used old code for trying only, my problem is:

    inside tab panel there are repeater subfields, if there are subfields it is fine to show the <li> tab but if no repeater subfields then I don’t need to show this <li> tab. (did you get me?).

    I am doing everything fine, but I am not able to echo all repeater fields in tab-pane, the first one will be missing, the first one will be echoed on first condition in <li>

    If you are not clear, I can send you wp-admin user and pass as well personally in your email.

  • <?php 
    $images = get_field(โ€˜bkg_slide_galleryโ€™, 'option');
    if( $images ): ?>
    <ul class="clearfix row">
    <?php foreach( $images as $image ): ?>
    <li>
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    <p><?php echo $image['caption']; ?></p>
    </li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>
Viewing 22 posts - 1 through 22 (of 22 total)