Support

Account

Forum Replies Created

  • I have a client I just created a site for with a products CPT that has a related products field. They have nearly 800 products and all of them are listed… in a “more” sorta way. When you scroll to the bottom of the current list the next few are loaded. The search works perfectly and loads pretty quickly.

    I would suggest that you also create a custom taxonomy for your email templates that allows the email templates to be sorted into “categories”. I’d probably name the taxonomy ’email-template-types’ ๐Ÿ™‚ In the future, when there are 1000’s or templates this may help the users find them faster.

  • Yes there is. $field also has the index ‘default_value’

    $field['default_value']

    On fields that allow a single choice return set it to a string.

    $field['default_value'] = 'my value'; Note, this could be for ACF4, at least I set single default values with a string and it works

    for fields that allow multiple choices return an array that holds the list of choices, you can also return an array of one choice for single item fields.

    
    $field['default_value'] = array (
      'value one' => 'value one',
      'value two' => 'value two',
      );
    

    Any time you want to know what you can set and what index of $field you need to alter to dynamically load it with a filter the best bet is to create a test field and then use the export feature to see what elements make the $field value. Any of the elements that are exported can be altered by your filter.

  • Inserting repeater fields into the DB is something I’ve just needed to do myself. There are a lot of fields to deal with.

    Each repeater field contains the number of rows of sub-fields.
    Each sub-field is actually named {repeater-name}_{count}_{subfield-name}

    So you need to insert the number of rows into “latlng_repeater”
    then for each row, say you have 2, you insert the values into:

    • latlng_repeater = 2
    • latlng_repeater_0_latlng_repeater_item_lat = lat value 1
    • latlng_repeater_0_latlng_repeater_item_long = long value 1
    • latlng_repeater_1_latlng_repeater_item_lat = lat value 2
    • latlng_repeater_1_latlng_repeater_item_long = long value 2

    To top this off, each of these fields has a corresponding field that starts with an _ whose value is the ACF field key. I had cases when working on my import where I needed to insert these values to get the field values to show on the front end without needing to open and save every post in the admin. I also has some cases where the imported values did not even appear in the admin without inserting these.

    • _latlng_repeater = field_53cf18c22ee37
    • _latlng_repeater_0_latlng_repeater_item_lat = field_53cf19022ee3b
    • _latlng_repeater_0_latlng_repeater_item_long = field_53d09ad6527ac
    • _latlng_repeater_1_latlng_repeater_item_lat = field_53cf19022ee3b
    • _latlng_repeater_1_latlng_repeater_item_long = field_53d09ad6527ac

    You really need to add some posts with all of the fields and then dig around in the database to figure out what you need to insert.

    Hope that helps.

    ~JH

  • You’re using ACF Pro, you don’t need the Options Page Addon, it’s included. You’re getting the error because the addon contains the same classes/functions that are already set up by ACF Pro.

  • I’m not sure. Are you sure about the taxonomy name being “product_cat_” I’m assuming it is based on the name of the template file being used.

    and you may need your action and function that you’d normally use for woocommerce. I don’t know a lot about how ACF plays with woocommerce.

    What I do know is that your original code the_field('custom_category_content'); was not working because you were not supplying it with the needed id value to get the value of a custom field that is attached to a term according to the ACF doc (http://www.advancedcustomfields.com/resources/functions/the_field/)

    You can make sure that $term_id = get_queried_object()->term_id; is returning a valid term ID.

    $object = get_queried_object();
    echo $object->term_id;

    you can even check the entire queried object to see what’s in there

    object = get_queried_object();
    print_r($object);
  • You would put the second part of your code just before the first part

    
    $term_id = get_queried_object()->term_id;
    $post_id = 'product_cat_'.$term_id;
    the_field('custom_category_content', $post_id);
    

    And this should all go into your custom taxonomy template (taxonomy-product_cat.php) where you want custom_category_content to be displayed.

  • You have to supply the_field function with the proper ID value when getting fields associated with a taxonomy term. See the end of “usage” on this page http://www.advancedcustomfields.com/resources/functions/the_field/.

    If this function is called on only tax/term templates you can use the following to get the current term id.

    $term_id = get_queried_object()->term_id

    The you combine that with the taxonomy name to get the field value

    $post_id = ‘taxonomy-name_’.$term_id.

  • You’ve been lucky ๐Ÿ™‚ there are a couple of sites I have that I cannot update to ACF5 because I’m using a some of the addons in the WP repo that haven’t been updated. Pretty popular ones so I’m hoping that will change when ACF5 is officially released. Not sure what I’ll do if they aren’t. I’d say that I’ll end up doing it myself but that all depends on time… until some future WP core update breaks ACF4, then it’ll be a mad scramble ๐Ÿ˜›

  • Please see: http://www.advancedcustomfields.com/resources/functions/the_field/

    You need to construct the correct $id value to get your field, which is a combo of the taxonomy slug and the term id.

    
    $id = 'category_'.get_queried_object()->term_id;
    the_field('my_cat_desc', $id);
    
  • Depends on if your using any addon fields from the WP repository and if those addons have been updated to support ACF5.

    I can’t answer the question about the license.

    If it me and I was buying now, I’d buy ACF5 and avoid the broken addons.

  • Hmm… your using ACF4… ACF5 has the option. I guess that needs to be thr first follow up question now (what version are you using ๐Ÿ˜› )

    First thing you should do is to turn on debugging while you’re doing development on a site. http://codex.wordpress.org/Debugging_in_WordPress. That way you’ll get hints as to why a page crashes and goes blank.

    Second, ACF4 compatible code.

    
    <?php $mf_post = get_field('manufacturer'); // changed variable name
       if ($mf_post) {
       $image = get_field('manufacturer_logo', $mf_post->ID); // changed to use object
       }
    ?>
    
  • On your review page, set the post object field for the manufacturer to return the id of the manufacturer post.

    
    /* 
       this would be somewhere in your post loop on review page
       set the manufacturer field to return id of manufacturer post object
    */
    $mf_post_id = get_field('manufacturer');
    if ($mf_post_id) {
      /*
         $mf_post_id should hold the manufacturer post id where the image
         image field is located. Now get the image field from that
         manufacturer post
      */
      $image = get_field('manufacturer_logo', $mf_post_id)
      /*
         $image should contain the value returned for the
         logo image field on the manufacturer post
      */
    }
    

    Hope that explains it better.

  • So you actually have 3 different things that need to be related.

    • Plays
    • People (Actors, Workers, Etc)
    • Performances

    This may not work for you, but, I’d probably create 3 custom post types, that match each of the above.

    Since the thing you’ll may be adding most often is performances that’s the one I’d probably use to tie the other them all together. Each play post would have information about just the play. Each person post would have just information about the person. Then when creating a performance post you’d select a play and the people involved.

    Anyway, you pick what bios go on each performance page using one of the relationship type fields, same with selecting the play.

    Hope that helps.

    ~JH

  • Where you have the_field('featured_image_for_mobile') try changing it to the_field('featured_image_for_mobile', $post->ID).

  • ACF4: Location rule: User is equal to All
    ACF5: Location rule: User Form is equal to…. you can choose

    This should add the fields to the profile edit pages I think.

    See this page for displaying values from a user: http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-user/

  • Hopefully I have this right, I’m assuming you have these people added on an options page.

    A better way to do this would be to have a Custom Post Type for adding the people and then use a relationship type of a field on the page editor where you want to allow them to be selected. If you’re not sure about adding CPTs check out Custom Post Type UI. You can set public to false in the post type so the posts are not accessible from the front end.

    Using and options page for your people you’re going to need to build a filter on the acf/load_field hook that gets all the values from the option pages and makes them choices for your checkbox field. I think displaying them on the front end would probably be a bit more complicated than the other way.

  • Text areas are not designed for shortcodes, but you could try something like:

    
    function text_area_shortcode($value, $post_id, $field) {
      if (is_admin()) {
        // don't do this in the admin
        // could have unintended side effects
        return;
      }
      do_shortcode($value);
      return $value;
    }
    add_filter('acf/load_value/type=textarea', 'text_area_shortcode', 10, 3);
    

    You could limit this to only a specific field by changing the hook to ‘acf/load_value/name={$field_name}’ or you could check $field inside the function for specific field names, or even add multiple add_filter() calls for different fields. Depends on how many text areas you want to filter and use shortcodes in.
    acf/load_value hook documentation

  • when using get_post_meta()

    The field that is your repeater field will return the # of rows in the repeater field.
    What you need to get is the meta value of the sub field meta key and the actual key will look something like
    {repeater-field-name}_{#}_{sub-field} where {#} is the index of the of the row, starting at 0.

    So you need to first get the value from the repeater field, then do a for loop and build the meta_key values and then get each sub field value.

    
    $repeater_value = get_post_meta($post_id, 'repeater_field_name', true);
    if ($repeater_value) {
      for ($i=0; $i<$repeater_value, $i++) {
        $meta_key = 'repeater_field_name_'.$i.'_sub_field_name';
        $sub_field_value = get_post_meta($post_id, $meta_key, true);
      }
    }
    

    what you do from there will depend on what is stored in the sub field.

  • Set up the Post Object field to return Post ID, then use that ID to get the field from your CPT.

    
    // this would be somewhere in your post loop
    $logo_post_id = get_field('post_object_field');
    if ($logo_post_id) {
      get_field('logo_image_field', $logo_post_id)
      // what you do next depends on if your image field returns 
      // Image Array, Image URL or Image ID
    }
    

    I usually like returning Image IDs and then using wp_get_attachment_image_src() to get the image size I need rather then sorting through an array or using the URL returned by ACF so that I can determine the size used in the code.

  • Neither does Nav Menu field. Unfortunately There aren’t replacements for some fields and I’m not sure that the authors have any plans of updating their addons in the near future. I’ve contacted some of the developers because I have sites using these plugins that I can’t update to ACF5. Honestly if I don’t see anything by the next time I have some free time to kill I’m going to have to build replacements…. unless someone else gets to it first.

  • okay, sorry, I didn’t do a test and after looking at the code I realize my mistake.

    The first part where I put “$term->term_slug” should have been the “Taxonomy Slug” for your taxonomy.
    'my-tax_'.$term->term_id
    which is, of course, what that code you posted is doing. My brain is just turning to mush ๐Ÿ˜›

  • you shouldn’t need to as long as it’s inside your loop

    
    foreach ( $terms as $term ) {
      $id = $term->slug.'_'.$term->term_id;
    }
    
  • The term_id is drawn from the term in your loop of the results from get_terms. WP does not automatically generate the id that you need. These are special IDs that ACF needs to locate your data.

    
    foreach ( $terms as $term ) {
    
        // The $term is an object, so we don't need to specify the $taxonomy.
        $term_link = get_term_link( $term );
    
        // If there was an error, continue to the next term.
        if ( is_wp_error( $term_link ) ) {
            continue;
        }
    
        // We successfully got a link. Print it out.
        echo '<div class="col-lg-3"><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a></div>';
    
        // show custom fields for the term
        // this id will be generated for each term
        $id = $term->slug.'_'.$term->term_id;
        the_field('my_first_custom_field', $id);
        the_field('my_second_custom_field', $id);
    }
    
  • You need to have something set on the page for “King’s Cross” that will always be exactly equal to the value selected in you “Special?” field. Then when you’re looping through your repeater (http://www.advancedcustomfields.com/resources/functions/get_sub_field/), if the value for special is set and it does not equal the value for the page then don’t display that set of sub fields.

  • Are you using something that looks like this:

    
    $id = $term->slug.'_'.$term->term_id;
    get_field('custom_field_name', $id);
    

    As shown on http://www.advancedcustomfields.com/resources/functions/get_field/ the id needed to get your custom field is a combo of the term slug and underscore and the term id.

Viewing 25 posts - 14,401 through 14,425 (of 14,467 total)