Support

Account

Forum Replies Created

  • @maidus – I wasn’t able to get the query for ACF select values to work, so I ended up doing custom taxonomies added to the post type, then doing individual queries for each. Was using this for populating the Isotope jQuery plugin for filtering products.

    <?php $headstyles = get_categories('taxonomy=mag_filter&post_type=product'); ?>
    <?php foreach ($headstyles as $headstyle) : ?>
    <div class="option" data-filter=".<?php echo $headstyle->slug; ?>"><?php echo $headstyle->name; ?></div>
    <?php endforeach; ?>
  • Thanks John – I was just in the process of reworking so that I’m using custom taxonomy as opposed to using the ACF field at all for that. Should be good to go now. Appreciate the help.

  • Reviving this thread in case this helps – was looking for the same thing, a way to reduce the initial height of WYSIWYG fields, as it makes the admin overly bulky for small content fields that need more control than Text Area.

    In digging, I found that wp-editor supports editor_height since v3.5 https://codex.wordpress.org/Function_Reference/wp_editor

    Would that allow for ACF to add height as an admin option?

    In the meantime, I’m using the following, but it prevents the client from being able to drag the size larger.

    /*-----------------------------------------------------------------------------------*/
    /*	Force Height of ACF WYSIWYG Fields
    /*-----------------------------------------------------------------------------------*/
    add_action('admin_head', 'my_custom_wysiwyg');
    function my_custom_wysiwyg() {
      echo '<style>
        .wp-editor-container textarea.wp-editor-area {
          height: 100px !important;
        } 
      </style>';
    }

    Thanks for the help,
    Jonathon

  • Was looking for something similar and found your post – not sure about the map link out, but on the content not being shown when the marker is clicked, did you include content inside the marker div?

    Such as:

    <?php 
       $location = get_field('address');
       if( !empty($location) ):
       ?>
       <div class="acf-map">
          <div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>">
             <?php echo $address['address']; ?>
             <?php echo $address['lat']; ?>
             <?php echo $address['lng']; ?>
          </div>
       </div>
    <?php endif; ?>
  • Hi @davemackey
    I just tried it out on a project I’m working on and it’s going to work out great. Users can add / remove rows and columns on their own, and conditionally add table headers.

    The snag I ran into was that in it’s simplicity, I needed a more complex layout – ability to sub-divide the fields as they are being entered. colspan could have worked, but there’s no control for that in the plugin.

    I first tried the jQuery route and got some help on Stackoverflow, but ended up instead using PHP to scan through the td cells for special characters, and inserted div wrappers to control the layout within those cells.

    Here’s the write-up on that in case it helps. http://stackoverflow.com/questions/43836976/table-user-controlled-content-with-specific-layout-styling-based-on-the-conten

    Going that route, it makes it pretty flexible.

    Cheers,
    Jonathon

  • @websul Glad it helped – I’m not sure about the other syntax, I did a lot of troubleshooting a while ago trying to figure things out for the User Field and that’s just what I had pieced together.

  • @websul If your Repeater Field name is Agenda, you might be able to use something like this:

    <?php
    // check if the repeater field has rows of data
    if( have_rows('agenda') ):
    
    echo '<ul>';
    
        // loop through the rows of data
        while ( have_rows('agenda') ) : the_row();
    
           echo '<li>';
    
            // display a sub field value
              $values = get_sub_field('user_field_name');
                if($values)
                $array = array_values($values);
                echo $array[5];
                }
    
           echo '</li>';
    
        endwhile;
    
    echo '</ul>';
    
    else :
        // no rows found
    endif;
    ?>
  • @websul – if you’re loading a User Name Field inside of a Relationship Field, then you might want something like:

    <?php 
    $posts = get_field('relationship_field_name');
    if( $posts ): ?>
        <ul>
        <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
            <?php setup_postdata($post); ?>
              <li>
                <?php
                $values = get_field('user_field_name');
                if($values)
                $array = array_values($values);
                echo $array[5];
                }
                ?>
              </li>
        <?php endforeach; ?>
        </ul>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>

    You wouldn’t need the sub_field in this case: http://www.advancedcustomfields.com/resources/relationship/

  • Thanks for the heads up – that’s odd, I went ahead and left the page, but it didn’t save the changes.

  • Rolled back to ACF Pro v5.0.5 (copied from a second install in dev that I hadn’t updated yet) and that allows me to edit / save the existing fields again as expected.

  • Perhaps this is a difference with newer versions of PHP – but the syntax that @spacewindow provides no longer works – it throws a somewhat vague PHP error of “Warning: Illegal string offset”.

    After a lot of digging, I realized that the User field doesn’t apparently return an actual array, but instead returns an array in a string, thus triggering the warning.

    Therefore, the following works for retrieving the associative array element by position for nickname.

    <?php
    $values = get_field('user_field_name');
    if($values)
    $array = array_values($values);
    echo $array[3];
    }
    ?>

    For reference on the keys depending on the User info you’re wanting to retrieve, using print_r(array_keys($values)); reveals the following:

    Array ( [0] => ID [1] => user_firstname [2] => user_lastname [3] => nickname [4] => user_nicename [5] => display_name [6] => user_email [7] => user_url [8] => user_registered [9] => user_description [10] => user_avatar )

    Just swap the number for the element you’re wanting.

    In case this helps anyone else save hours of digging.
    J

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