Support

Account

Forum Replies Created

  • Running
    $user = update_field( 'field_6004677a93a7f', $supplier_description, '$user_{$user_ID}' );

    after
    $user = wp_insert_user( $userdata );

    Seems to break the user registration. Is running the update against the $user variable the best way of updating the ACF field?

    Thanks for your help by the way, this is most excellent of you.

  • How is there a post ID if I’m registering a new user? Isn’t the ID created when the user is?

  • seriously any help with this would be appreciated.

  • Awesome Elliot thank you, I shall spend some time learning about has_sub_field loop. I really love this plugin, it has completely transformed the way I do business.

  • I’m assuming for second that you realise that this is a WORDPRESS plugin that was made for WordPress users and developers, who don’t necessarily count themselves as php Gurus. I did pay for this product and as such require some support.

    Can you please humour me with a working example please. I tried this below but received to values.

    
    <?php 
    		 
    if(get_sub_field('testsubfield'))
    {
    	$attachment_id = get_sub_field('testsubfield');
    	$url = wp_get_attachment_url( $attachment_id );
    	$title = get_the_title( $attachment_id );
    	echo '<ul>';
    	
    	while(has_sub_field('testsubfield'))
    	{
    		echo '<li><a href="' . $url . '" class="wpaudio">' . $title . '</a></li>';
    	}
     
    	echo '</ul>';
    }
     
    ?>
    
  • This code using get_sub_field in the loop gives me the exact same results as the code above.

    
    <?php 
     
    if(get_field('testlabel'))
    {
    	echo '<ul>';
     
    	while(has_sub_field('testlabel'))
    	{
    		echo '<li><a href="' . $url . '" class="wpaudio">' . $title . '</a></li>';
    	}
     
    	echo '</ul>';
    }
     
    ?>
    
  • Hi @elliot

    Screenshots attached, top level field is called “testlabel” with repeater. Subfield level is called “testsubfield” with file.

    The file field “testsubfield” is set to File ID.

    They are attached to display on a custom post type called “acts”. The code I’m using is below which includes your last replies suggestions. When I made this field it didn’t show 75 results show just ignoring the problem for now.

    Thanks

    
    <?php 
    $attachment_id = get_sub_field('testsubfield');
    $url = wp_get_attachment_url( $attachment_id );
    $title = get_the_title( $attachment_id );
    ?>
            
            <?php if(get_field('testlabel')): ?>
     
    	<ul>
     
    	<?php while(has_sub_field('testlabel')): ?>
     
    		<li><a href="<?php echo $url; ?>" class="wpaudio"><?php echo $title; ?></a></li>
     
    	<?php endwhile; ?>
     
    	</ul>
     
    <?php endif; ?>
    
  • I can confirm I am seeing “Array” as the href, however when I replace

    get_field('add_audio_file')

    with

    $attachment_id = get_sub_field('add_audio_file_repeater');

    It retrieves nothing. On top of that, for some reason there are 75 entries for adding a file from the moment I create a file repeater field.

  • Awesome Rich thanks, culmination of a long day and not realising I had chosen the “AND” rule instead of the “OR” rule, as I had two rules for two custom post types.

    Thanks again

  • Duuuuude!

    Ok I didn’t realise there were image options, and it was set to “Object”. Changing it to Image URL fixed it.

    Total oversight on my part. Thank you kindly for the quick reply!

  • By the way chaps thanks incredibly for the help, I was ready to gauge out my eyes. 🙂

    Mike J

  • No matter I fixed it. The problem was with “get_field” I replaced it with “the_field”

    
    <?php
     
    global $post;
     
    // load all 'category' terms for the post
     $terms = get_the_terms($post->ID, "product_brand");
     
    // we will use the first term to load ACF data from
    if( !empty($terms) )
    {
    	$term = array_pop($terms);
     
    	$custom_field = the_field('contact_info', 'product_brand_' . $term->term_id);
     
    	// do something with $custom_field
    }
     
    ?>
    
  • I’m afraid changing “category_” to “product_brand_” had no effect. It’s almost like that line has no way of getting the id of the current term. The address reads like this http://site/?product_brand=1st-call-mobility where “1st-call-mobility” is the term of the product_brand taxonomy.

    “contact_info” is my ACF field slug, and “Brands” is a Custom taxonomy, whose slug is “product_brand”. Its a Woocommerce plugin, essentially for adding manufacturers to Woocommerce products.

    I’ve tried printing this code before and it just wasn’t picking up the terms custom field in the print either.

    Do I perhaps need to define “$custom_field” somewhere?

  • @wells5609 @elliot
    Ok, so I managed to get this code to work to get a specific taxonomy ID (so I know the system is working)

    
    <p><?php // the_field('contact_info', 'product_brand_14'); ?></p>
    

    But trying to get the same terms of the current Term ID being displayed, doesn't work however. (In my “archive-brands” template.) Even with array_pop.

    
    <?php
     
    global $post;
     
    // load all 'category' terms for the post
     $terms = get_the_terms($post->ID, "product_brand");
     
    // we will use the first term to load ACF data from
    if( !empty($terms) )
    {
    	$term = array_pop($terms);
     
    	$custom_field = get_field('contact_info', 'category_' . $term->term_id );
     
    	// do something with $custom_field
    }
     
    ?>
    

    Thanks guys

  • Your help documents say that to Display a field in my Archive template all I need do is include this code

    
    <p><?php the_field('field_name', 'category_7'); ?></p>
    

    With my relevant data. However I can’t seem to get this to work either. Is it possible you could perhaps include a code snippet example for every setup that works on fresh, unmodified installs? Whether it be for adding WYSIWYG’s or Calender or, like in my case, a simple text field. This would certainly help me a lot just now and I suspect a few more out there.

    Great looking new forum btw 🙂

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