Forum Replies Created

  • Hello…

    Can you be more specific please? What form do you mean?

    AdSense ads can be inserted in a number of ways… are you editing HTML directly, or are you adding content to a post or page?

    Let me know and I will offer a solution πŸ™‚


  • Hi there!

    I will attempt to help… I have a question though…
    .. how do you want to display the values?

    For example.. you could append it to the content of a post, so then you would filter the_content() … and within your function you can write a conditional statement for a specific post type.

    In general, when you have access to the Post ID, you can determine the post type using the code below:

    if ( get_post_type( get_the_ID() ) == 'slug_post_type' ) {
        //if is true

    Depending on the function you are using, you may have access to the Post Object, or the Post ID directly… so you would replace get_the_id() with however you get the Post ID in the given situation.

    Hope that helps! But please let me know if you need further clarification, and let me know the very specific goal and I can offer more direction if needed.

    Thanks for your inquiry,

  • HI @pixelsmith

    I ran into the issue before (more than once)… where WP was creating 1×1 images for all image sizes. I guess… since they are all the same size, they all have the same URL? (I can’t be sure on that though).

    At any rate… one time… it was a plugin that was creating 1×1 images for all sizes.. like: add_image_size( ‘thumb-1’, 1, 1, true )

    …another time it was image compression software (like WP Smush IT, Shortpixel, Photon) that was messing with image sizes that caused it. I can’t remember the image compression software now (it wasn’t any of the ones listed above tho).

    To fix… I removed the tools… regenerated thumbs, and all was good.

    So… not sure if it’s an ACF issue… it might have happened within the Media Library during upload by some other hook.

    Hope you are able to sort it out, and it’s a simple fix!

  • Hello… when referencing an ACF field, sometime you need to pass in the “post/page/CPT ID”… other times it assumes *current* post/page.

    It depends where you are creating the data… if it’s an Options Page, pass in “option” as the second parameter, like:

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

    Hope that helps!

  • Hi @ikazi

    Something like the code below should do the trick…

    In it, I loop through the repeater, and add only non-expired dates to an array..
    .. then I sort it… then… you can loop through the result set. Give it a try and let me know πŸ™‚

    $repeater = get_field('list_of_date');
    foreach( $repeater as $key => $row ) {
      if ( strtotime( $row['date_end'] ) > strtotime( date() ) ) { // not expired, add to array
        $column_id[ $key ] = $row['date_start'];
    array_multisort( $column_id, SORT_ASC, $repeater ); // sort the array
    foreach( $repeater as $row ) {
      // loop through the array


  • Hey @benheath

    It would be great if there was a hook we can tap into each time a new Taxonomy was created. That process is being done with JavaScript, and I don’t know of any hook at that step. But that would present another issue… the User could end up not using the Term in the end… so that would need more thinking anyway.

    With that said… I asked myself these questions..

    I know it would be easy to run add_term_meta() on ‘save’… that’s not an issue.

    What I would like to know is…

    1) How would we know if a term has been newly added by this User?
    2) Can we assume that if ‘term_author_id’ is NOT set, it’s new? Probably.

    So… after a Post is Published/Saved… even within the wp_insert_post hook, we can:

    Iterate through all terms attached to *that* post. Look for ones that don’t have term_author_id set, and assume (safely) that the current User came up with that term.. then we run run add_term_meta() function.

    I don’t have the exact code for you… but do it bit by bit, and use var_dump each step of the way to see if you are getting what you are supposed to.

    Here’s a good reference:

    Also… there are heaps of functions specific to Terms/Taxonomies for WordPress… get_terms and get_the_terms seem to be good choices here.

    Sorry that I couldn’t be more help, but this should get you moving along further I hope!

  • Hi @benheath

    There’s probably a couple places you can jump in with your add_term_meta() code I would guess, but acf/save_post is probably a really good choice. Do you have reservations about using that?

    Sometimes I find it tricky when doing things during the “save” process whether ACF fields are set yet or not… whether to use the Field Key, or whether to use the $POST object… and of course, it all depends on the purpose…

    … but my new favourite action hook is: wp_insert_post

    … maybe give that one a try if you have troubles with acf/save_post … it works for me every single time when coupled with ACF custom fields.

  • Hello @pixeldesignsuk

    Am I correct in thinking that you are in fact looking for “Terms” of a “Taxonomy” and not actually the “Taxonomies” of a CPT?

    If you are looking for “Taxonomy Terms” (as opposed to Taxonomies) which makes more sense if looking for the “slug”, then you could try this:

    $field['choices'] = array();
    $terms = get_terms( array(
      'taxonomy' => 'custom_taxonomy_name',
      'hide_empty' => false,
    if ( $terms ) {
      foreach ( $terms as $term ) {
        $choices[$term->slug] = $term->slug . ' : ' . $term->name;


  • Option buttons only allow for one option chosen (when they all share the same name), but I’m sure you know that πŸ™‚

    I managed to use checkboxes as a group in a quick test that I just did.

    I only did it within Chrome Dev tools, but it proved to be pretty easy if you have some CSS and JavaScript skills.

    I don’t know if it’s planned to create a Checkbox group, but if it’s important to you right away, you can apply the same Class as the button group, to a group of checkboxes. Then you can use JavaScript to add the “selected” class to the Label when clicked (and remove it when clicked again). Plus you need to remove some right margin between the boxes… then it suddenly looks exactly the same, and allows for multi-select.

    I haven’t the time right now, else I would have done it for you. Seems like a fun quick project. I will pass on the suggestion to make it part of ACF.

  • Hi @darusharp

    When passing an empty array to ‘include’, all results are returned…
    .. which I guess is what you are saying πŸ™‚

    I tested the above scenario, and when no posts are chosen, $ids is in fact empty…

    You can test if it *has* any values by doing:

    if ($ids) {
      $args = array(
        'numberposts' => -1,
        'post_type' => 'daylily', //my custom post type
        'include' => $ids,
        'orderby' => 'title',
        'order' => 'ASC',
      $wishlistitems = get_posts($args);
    } else {
      echo 'No one is wishing for anything at the moment';

    Hope that helps!

  • Hi there,

    Yup… just did it… I was using Tabs and Repeaters… both of which are Layout Fields.

    To do it… I just used the ‘Export’ feature to generate the PHP code.

    Go to: Custom Fields -> Tools -> (choose your Field Group) -> (click ‘Generate export code’)

  • Hi Neil,

    I received some feedback about my reply… and I stand corrected. Here’s the feedback which should be helpful to you:

    The WP_Query docs feature heaps of ‘meta’ args examples including ’empty’ –

    I believe the meta_query value can be set to ‘NOT EXISTS’.
    Also, a repeater field with 0 rows will be saved with a value of ‘0’, not ‘false’.


    My apologies for incorrect info in my original reply.

  • Hello,

    I guess I am confused on what you are asking…

    With this feature (whether you are adding fields to Menus, or adding fields to Menu Items), you will only ever see Menus within Location Rules… not Menu Items.

    Adding fields to Menus, essentially lets you… create new Menu Items.
    Adding fields to Menu Items, essentially lets you… add extra bits to Menu Items.

    So… there is no bug here that I see. Your screenshot shows what should be shown.

    If you haven’t resolved this yet… please let me know your goal… and I will explain how to accomplish it πŸ™‚

  • Hello..

    There are probably many ways to tackle this. Not sure the best.

    You could dynamically create the options within the Select, giving you full control of the text of the ‘Select’ option. Just give it an empty or NULL value, so the validator won’t look at it as an *actual* choice.

    JQuery lets you change values/labels on-the-fly as well.

    Translation may be an approach.

    Let me know how you tackle it!

  • Hi @p_cameron

    I’m not sure how I would tackle this in a final product, but here are some ideas that I had while thinking about it… they aren’t perfect solutions, but may be worth exploring if you can’t find the proper filter. I looked at all the filters as well, and can’t see any that may suit the situation.

    However, you may be able to explore the select2_init here.


    1) You could switch to a select, and dynamically populate it, settings some items to disabled (if they have children).

    2) You could use AJAX in the footer to query the same Posts you are presenting in your Post Object, and then loop through them, and dynamically disable items.

    Hope that helps get you moving along. Let me know how you went about it!

  • Hello..

    I’m not 100% sure what you are asking… but, from what I do understand, it sounds like.. yes, it can be done.

    Are you saying that:

    a) you want to assign a post to a category
    b) display content *below* that post, depending on the category?

    If so… here would be my approach:

    1) Create an Options Page
    2) Add a Repeater Field to the Options Page (call it something like: category-content)
    3) Add 2 Sub-Fields to the Repeater, one to choose the Category, one to add the content (a WYSIWYG fields perhaps, or a Textarea)
    4) Then… in a custom function, you can leverage the WordPress filter: the_content to append the content to a post, depending on the category

    I realize that doesn’t tell you *how* to do it precisely, but if I am correct in what you want… hopefully you have a game plan now where you can dig in and figure it all out.

    It’s all doable with ACF and a little PHP code.

    Hope that helps!

  • Hi @neil

    Did you try looking for false?

    'meta_key' => 'repeater_field',
    'meta_value' => 'false',

    Let me know!

  • You could go back to using the Date Picker and use JavaScript and JQuery to disable the fields.

    Here’s some code that I used in a recent project to do that, which demonstrates how to Disable various field types (Date Picker, Button Group/Radio Buttons, Select, Textarea, Repeater, WP Title)…

    /* START: Prevent editing of Support Ticket fields for specific roles */
    function cc_prevent_editing_support_ticket_fields_after_publish() {
      global $pagenow;
      if ( !is_admin() ) { return; } // only in wp-admin
      if ( $pagenow=='post-new.php' ) { return; } // not for 'new posts'
     // only for specific post type(s)
      $post_types = array('supporttickets');
      if ( !in_array( get_post_type(), $post_types ) ) { return; }
     // only for specific role(s)
      $user = wp_get_current_user();
      $user_role_id = $user->roles[0];
      $exempt_roles = array('administrator', 'owner', 'controller');
      if ( !in_array( $user_role_id, $exempt_roles ) ) {
    <script type='text/javascript'>
      ( function ( $ ) {
        $( document ).ready( function () {
          $('#idOfDatePicker .acf-date-picker .hasDatepicker').prop('disabled','disabled'); // disable 'Date Picker' field
          $('#acf-field_59d9867971a81').prop('disabled','disabled'); // disable 'Select' field
          $('input[type="radio"][name="acf[field_59d94c7897682]"]').prop('disabled','disabled'); // disable 'Button Group' or 'Radio Buttons'
          $('#title').prop('disabled','disabled'); // disable WordPress Post Title
          $('#acf-field_59d968a0dc7a7').prop('disabled', true); // disable 'Textarea' field
          $('.acf-field-59daa7de17e69 .acf-actions').hover(function() {
          }); // removes delete button from 'Repeater Rows' on 'hover'
          $('.acf-field-59daa7de17e69 .acf-actions').css('display','none'); // removes delete button from 'Repeater Rows'
          $('.acf-field-59daa7ae17e68 a[data-event="add-row"]').remove(); // remove 'Add Row' button for 'Repeater' field
          $('.acf-field-59daa7ae17e68 a[data-event="remove-row"]').remove(); // remove 'Remove Row' button for 'Repeater' field
      }( jQuery ) );
    add_action( 'edit_form_advanced', 'cc_prevent_editing_support_ticket_fields_after_publish' );
    /* END: Prevent editing of Support Ticket fields for specific roles */

    Hopefully that helps… you can target any HTML element in various ways and disable them. You can even add a specific ID or Class to your Date Picker fields in the Edit Fields screen for the field (next to ‘Wrapper Attributes’), and then target it that way (like I did at the top of JavaScript).

    ‘Disable’ is essentially the same as ‘Read Only’ for most purposes. However, when creating a *new* post, and you give a field a default value AND disable it, the value won’t Submit. So, if you are doing that… you will need to add more JavaScript that re-enables the form field upon click of the Submit button.

    At any rate, the above should get you going if you want to disable fields other than just the Basic fields.

  • Hi @vguenichon

    Here’s some code that I managed to get working to display details about the sub fields within a repeater:

    Note: I left my debugging statements intact, but commented out.

     // repeater field - this can be set dynamically within your loop of course... I set it statically for testing
      $field_obj = get_field_object( 'field_59dbae70e1416' );
      if ( $field_obj ) {
        if ( $field_obj['type'] == 'repeater' ) {
     // the array of sub fields within the repeater
          $sub_fields = $field_obj['sub_fields'];
          foreach( $sub_fields as $sub_field ) {
            echo '<p>key: ' . $sub_field['key'] . '<br />';
            echo 'label: ' . $sub_field['label'] . '<br />';
            echo 'name: ' . $sub_field['name'] . '</p>';
          //echo '<pre>';
          //echo '</pre>';
  • Hello… rather than re-do the code… what about a workaround to ‘cast’ your singular value as an array?


    $value = 1;
    $value = (array)$value;
    if ( is_array($value) ) {
      echo 'Yes, it is an array!';
    } else {
      echo 'Nope, not an array :(';
  • yes, different CPT’s… one-to-one, one-to-many, many-to-many πŸ™‚

  • Hi there… this is a question that your web host would need to assist with. It has something to do with a setting in php.ini or .htaccess from what I garnered with a quick Google search. I hope you get it sorted!

  • Sounds good. I do suggest that you create a custom plugin, rather than modify the functions.php file of your theme. That way… if you ever switch themes, things should continue to work as expected.

    Creating a simple plugin is quite easy. I always use the free plugin Pluginception. Once active, it creates a new option under Plugins called “Create a Plugin” or something like that. Then you just have to give it a name… then Save it… Paste in the code, save again, and test.

    Hope you feel confident giving this a try. Once you succeed with it your confidence will surely grow. I will keep tabs on this thread and reply at least once daily!

  • never mind.. I misunderstood UGC… you mean a front end form? ACF has that as well.

  • Hi Dave..

    Would the ability to use shortcodes to get ACF field data be helpful? It’s built into ACF.. and many tools allow for shortcodes… not sure if that feels like a good solution to you… I am interested to see what you you come up with..

Viewing 25 posts - 1 through 25 (of 118 total)