Support

Account

Forum Replies Created

  • I just did a test on a site using 4.4.11 and IE11 and it seems to be working for me.

    Try deactivating other plugins and/or switching themes to see if you can clear up the problem. More than likely there is some JavaScript error in IE that is causing the editor to not display correctly.

  • There are several ways that you can do this, the most straight forward is to loop through all of your values outside the loop and gather all of the values into an array, checking to make sure there are not duplicates

    
    $values = array();
    
    // your loop starts
    
    // somewhere inside your loops where you're getting the value
    $value = get_sub_field('field_name');
    if (!in_array($value, $values)) {
      $values[] = $value;
    }
    
    // after the end of the loop loop through the
    // collectionof $values and echo what is needed
    

    The second method would be to create an acf/update_value filter https://www.advancedcustomfields.com/resources/acf-update_value/. In this filter you can possibly look at the value and store some other post meta value that has the list so you can just get this value instead of doing the loop. This would be pretty complex and would essentially just move the code from the front end into the admin and would probably require additional coding.

    Another method would be to use an output buffer http://php.net/manual/en/book.outcontrol.php

    
    ob_start();
    
    // your current loop for outputting content here
    // with additions as shown in the first option for gathering values
    
    // after the loop, output the link and font values
    
    // the echo the output buffer wherever it is the content needs to be displayed
    
    echo ob_get_clean();
    
    
  • I just ran the same test on with a text field and I’m not getting any extra content stored. So the question is, where is the extra content coming from? ACF is not adding it.

    The first step is to see what my be causing it by deactivating plugins and switching themes.

  • Even for someone that might be considered and advanced php guy, your fieldset with 4 nested repeaters is something that I’d consider complex.

    Not exactly sure what you’re trying to do or why. What is the reason that you need to get a specific value from a specific field in all of these nested repeaters outside of the loop where they are going to be displayed?

  • This can also happen because of at JavaScript error or a PHP error during the AJAX request.

    What are the location rules for the field groups that are not appearing?

  • Without knowing the exact index of each nested repeater it will be impossible to get a value from a specific nested sub field with such a complex setup. But in order to loop through this structure outside of the loop is to provide the post ID for the first

    
    if (have_rows('page', $post_id)) {
      while (have_rows('page', $post_id)) {
        the_row();
        // nested loops here
      }
    }
    

    If you do know the exact index at each lever you can use get_post_meta() as suggested by @willh, this is how the meta key can be constructed. nested field indexes start at 0 and not 1.

    
    $meta_key = "page_{$index}_row_{$index}_columns_{$index}_elements_{$index}_field_name";
    $value = get_post_meta($post_id, $meta_key, true);
    
  • ah, I thought you meant the message itself. Yeah, I’ve seen that happen when I add HTML to the label. I usually just ignore that since it’s in the admin for the field group and I’m the only one that’s going to see it.

  • There isn’t anything in the URL field that I can find that should be altering the URL to lower case. I just tested this on one of my test sites and ACF is not altering the URL to lower case.

    This means that you have something else that is causing it, either in another plugin or in your theme.

  • Well, that’s because I forgot something important

    
    while ($query->have_rows('artikel', $post_id)) {
      the_row(); // I forgot this
    
  • I don’t think I really understand what you trying to do. If you’re going to use values from a repeater then you’ll need to loop through the repeater wherever it is that you’re showing it. What am I missing?

  • More than likely there is a filter that’s interfering with the display of field groups, here’s a related topic https://support.advancedcustomfields.com/forums/topic/custom-fields-not-showing-for-non-admin/

    The first thing you need to do is deactivate all other plugins and change to a standard theme to see if you can clear up the issue and narrow down what could be causing the conflict.

  • The first item might be a bug and should be reported here https://support.advancedcustomfields.com/new-ticket/

    As for the second, many people put HTML in there (me included) to format the message in a specific way. Like any field that accepts HTML, being a developer, you should make sure your HTML is valid and correct.

  • Are you using ACF 4 or 5?

    In either case you need to supply the correct post ID value. In ACF for this is "{$taonomy}_{$term_id}". In ACF 5 you can use the same value or you can use "term_{$term_id}"

    In a tax archive template you can get the term ID like this

    
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;
    

    To get the field you should either use

    
    // the_field() echos the value and you do not need to include your own echo statement
    the_field('game_publisher', $taxonomy.'_'.$term_id);
    

    or

    
    echo get_field('game_publisher', $taxonomy.'_'.$term_id);
    

    for more information see https://www.advancedcustomfields.com/resources/get_field/ Get a value from different objects

  • 
    function my_acf_load_value($value, $post_id, $field) {
      // current post id is passed, no need to figure it out
      if (have_rows('artikel', $post_id)) {
        // set up an array to hold values
        // this is becuase a repeater field could have many
        // and will make it easier to concatinate them
        $values = array();
        while (have_rows('artikel', $post_id)) {
          // get value of sub field without formatting
          // so that it will be the ID of the post object
          $post_object_id = get_sub_field('artikel_navn', false);
          // get the field value from the related post object
          // and add to the array
          $values[] = get_field('tekst', $post_object_id);
        } // end while have rows
        // after the loop, implode the values
        $value = implode(', ', $values);
      } // end if have rows
    
      return $value;
    }
    add_filter('acf/update_value/name=meta_beskrivelse', 'my_acf_load_value', 10, 3);
    
  • It is a little confusing, yes. The documentation does refer to an object, but it has always been returned as an array and this is seen in the code example for the image field where array values are used. I’m sure that the documentation will eventually be updated. The best way to get concerns like this to the developer is to open a new support ticket here https://support.advancedcustomfields.com/new-ticket/.

  • Just keep the previous value in a variable and if the new one is blank then use the old one, something like this.

    
    if (have_rows('repeater')) {
      $prev_value = '';
      while (have_rows('repeater')) {
        the_row();
      }
      $value = get_sub_field('sub_field');
      if ($value) {
        echo $value;
        $prev_value = $value;
      } else {
        echo $prev_value;
      }
    }
    
  • I think that sub_field_1 and sub_field_2 in that example are supposed to represent the field names of the sub fields, but using the field keys is always the better option when using update_field(). The second example in the same code for flex fields better illustrates the way the value array needs to be for repeaters, with the exception of the acf_fc_layout index. Repeaters and flex fields work the same way with the exception of the layout name.

  • the array for your repeater should look like this

    
    $value = array(
      // nested for each row
      array(
        // field key => value pairs
        'field_59606dc9525dc' => 'value for row 1'
      ),
      array(
        // field key => value pairs
        'field_59606dc9525dc' => 'value for row 2'
      ),
    );
    

    I think that this will do it

    
    foreach ($wpbb_xml_params->features->children() as $second_gen) {
        $feature_value = (string)$second_gen;
        $value[] = array( 'field_59606dc9525dc' => $feature_value );
    }
    update_field( 'field_59606db8525db', $value, $wpbb_job_post_id );
    
  • Using your example, the width and height of the above images will be at
    $image['sizes']['medium-width'] and $image['sizes']['medium-height']

    here is that output of all values from an example gallery with one image

    
    Array
    (
    
      [0] => Array
        (
          [ID] => 389
          [id] => 389
          [title] => atomic-bomb-explosion
          [filename] => atomic-bomb-explosion.jpg
          [url] => .../wp-content/uploads/jpg/atomic-bomb-explosion.jpg
          [alt] => 
          [author] => 1
          [description] => 
          [caption] => 
          [name] => atomic-bomb-explosion-2
          [date] => 2017-06-14 16:20:25
          [modified] => 2017-06-14 16:20:25
          [mime_type] => image/jpeg
          [type] => image
          [icon] => .../wp-includes/images/media/default.png
          [width] => 1400
          [height] => 1050
          [sizes] => Array
            (
              [thumbnail] => .../wp-content/uploads/jpg/atomic-bomb-explosion-150x150.jpg
              [thumbnail-width] => 150
              [thumbnail-height] => 150
              [medium] => .../wp-content/uploads/jpg/atomic-bomb-explosion-300x225.jpg
              [medium-width] => 300
              [medium-height] => 225
              [medium_large] => .../wp-content/uploads/jpg/atomic-bomb-explosion-768x576.jpg
              [medium_large-width] => 474
              [medium_large-height] => 356
              [large] => .../wp-content/uploads/jpg/atomic-bomb-explosion-1024x768.jpg
              [large-width] => 474
              [large-height] => 356
              [post-thumbnail] => .../wp-content/uploads/jpg/atomic-bomb-explosion-672x372.jpg
              [post-thumbnail-width] => 672
              [post-thumbnail-height] => 372
              [twentyfourteen-full-width] => .../wp-content/uploads/jpg/atomic-bomb-explosion-1038x576.jpg
              [twentyfourteen-full-width-width] => 1038
              [twentyfourteen-full-width-height] => 576
            )
    
        )
    
    )
    
  • This is not something that ACF can control. When a field group is first added the default, original location is decided by when WP invokes the hook for displaying custom meta boxes.

    After this point, any user can drag these sortable meta boxes to any order they wish and WP will remember that order. In the _usermeta table there is an entry for each user and each post type. For example for posts the meta_key is meta-box-order_post the key is created like "meta-box-order_{$post_type}". This db entry stores a serialized array that records the order that the sortables were in the last time that the user saved a post.

    In order to take control and force these to a specific configuration for your post you would need to get this entry and update it every time the user logs in, or saves a post, or at other times to ensure that they are in the order that you want them.

    Check out this for some possible solutions https://wordpress.stackexchange.com/questions/124330/metabox-layout-for-all-users

  • Hiding the submit button will not prevent the form from being submitted. Why not just not display the form at all if the user is not logged in?

  • This is a feature that will be added in V5.6.0 which is currently in beta https://www.advancedcustomfields.com/blog/acf-pro-5-6-0-beta1/

  • Look at https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters and look for ‘orderby’ with multiple ‘meta_key’s and also here https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/

    This should probably be done with a pre_get_posts filter to alter the main query. This is an example using what you’ve posted to give an example.

    
    $args = array(
      'numberposts' => -1,
      'post_type' => 'locations',
      'meta_query' => array(
        'state_clause' => array(
          'key' => 'state',
          'compare' => 'EXISTS',
        ),
        'city_clause' => array(
          'key' => 'city',
          'compare' => 'EXISTS',
        ),
      ),
      'orderby' => array(
        'state_clause' => 'ASC',
        'city_clause' => 'ASC',
        'title' => 'ASC'
      )
    );
    $the_query = new WP_Query($args);
    

    The above will order all of the posts so that they end up being grouped together by state and then city. The next step is that as you’re looping through the posts you need to look at what the state/city of the post is and compare it to the previous post. This can be a little confusing because of the circular logic of possibly outputting closing tag for elements before outputting the matching opening tags for those elements.

    
    if ($the_query->have_posts()) {
      // variables to hold values from previous post
      $last_state = '';
      $last_city = '';
      
      while ($the_query->have_posts()) {
        // get state and compare it to the previous post
        $this_state = get_field('state');
        if ($this_state != $last_state) {
          // the state has changed
          if ($last_state != '') {
            // close the post UL, city DIV, and state DIV that we'll open next
            // this will be skipped if this is the first post
            // because $last_state will be empty
            echo '</ul></div><!-- .city --></div><!-- .state -->';
          }
          echo '<div class="state"><h2>'.$this_state.'</h2>';
          // clear $last_city
          $last_city = '';
          // set $last_state to $this_state
          $last_state = $this_state;
        } // end if new state
        // get the city and compare to previous post
        $this_city = get_field('city');
        if ($this_city != $last_city) {
          // the city has changed
          if ($last_city != '') {
            // close the post UL, city DIV we'll open next
            // this will be skipped if this is the first post for city
            // because $last_city will be empty
            echo '</ul></div><!-- .city -->';
          }
          echo '<div class="city"><h3>'.$this_city.'</h3><ul>';
          // set $last_city to $this_city
          $last_city = $this_city;
        } // end if new city
        ?>
          <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
        <?php 
      } // end while have posts
      // we need to close the last set of elements that were opened
      echo '</ul></div><!-- .city --></div><!-- .state -->';
    } // end if have_posts
    
Viewing 25 posts - 8,726 through 8,750 (of 14,470 total)