Support

Account

Forum Replies Created

  • Alright, fair enough. Thanks for the quick reply!

    Hopefully another similar solution gets put into the core soon.

  • @hube2 I noticed this is yours: https://de.wordpress.org/plugins/acf-medium-editor-field/

    Any reason why it’s been taken down? I’d like such functionality, but I really don’t want to make my clients depend on something that is potentially out of production.

  • I messed around with a code to collapse with shift-click on Flexible Content ‘headers’. Shift-click felt more natural than a button somewhere on the page.

    It also works with the pretty-edit-pen icon from ACF Extended. Not further tested on other Extended settings.

    It checks if the currently clicked header is open/closed, and applies open/close to all other elements accordingly. Some weird timeout function was required not to interfere with (probably) default click behaviour?

    For anyone interested you can add this to admin JS:

        // Function to handle shift+click event on .acf-fc-layout-handle
        $('.acf-fc-layout-handle').on('click', function(e) {
            if (e.shiftKey) {
                e.preventDefault();
                closestLayout = $(this).closest('.layout');
    
                if (closestLayout.hasClass('-collapsed')) {
                    // console.log('Layout is hidden');
                    setTimeout(function(){
                        $('.acf-flexible-content .values .layout').removeClass('-collapsed');
                        $('.acf-flexible-content .acfe-fc-placeholder').addClass('acf-hidden');
                      }, 1);
                } else {
                    // console.log('Layout is visible');
                    setTimeout(function(){
                        $('.acf-flexible-content .values .layout').addClass('-collapsed');
                        $('.acf-flexible-content .acfe-fc-placeholder').removeClass('acf-hidden');
                      }, 1);
                }
            } 
        });
  • Hi John,

    Thanks, but as explained i’d have to change tens or hundreds of fields in a few dozen files.

    Is there a better way to just force *any* ACF fields between a piece of code to return a certain page – without modifying every individual get/the_field?

  • Wow how did you give this solution one day before I needed it. That’s brilliant, and works like a charm!

  • I solved it by creating a CSS class from the value before the loop, then hide/show it based on that class.

    Not ideal as it’s unnecessary HTML, but works for this situation.

  • I don’t think it works because it lives inside another Flexible Content row (should have specified), which also requires get_sub_field – right?

  • That’s brilliant, seems to work well – thanks!

  • @hube2 – I guessed it would work automatically, but I re-read your post and saw this:

    Part of the parent theme code is checking to see if a child theme is being loaded and if it is then it adds a load point to load the field groups from the parent theme.

    Could you elaborate a bit on this, how would I set this up?

  • I was using get_stylesheet_directory_uri in the parent theme so it threw it for a loop 😉

    That said, I currently have this setup:

    Network admin
    – English “main site” with the parent theme enabled
    – German, child-theme from EN
    – Russian, child-theme from EN

    However, when I add/edit ACF Custom Fields they don’t sync/show up in the DE/RU version. Am I missing something?

  • @hube2

    I do not sync field groups to all sites in a mutlisite installation. There is not really any need to do this.

    This is what I do.

    I create a theme with an acf-json folder and I activate this theme on only one site. This is my dev site. This is the only place where changes to a field group are made.

    Any other site in the network that uses this theme is set up using a child theme. Part of the parent theme code is checking to see if a child theme is being loaded and if it is then it adds a load point to load the field groups from the parent theme. No syncing to these sites is needed.

    I’m trying this solution, but even with all plugins disabled I keep getting endless loading (white screen) when I activate the child theme and visit the front-end.

    I’ve tried manual child theme and a plugin “child theme creator” but neither work. Any ideas? I’m nog 100% knowledgable on multisites.

  • Currently giving Gutenberg another go (instead of Flexible Content taking over the old editor) and this still is an issue.

    Unfortunately the only real solution is just to force the mode => ‘edit’ and just have people edit in the main editor instead of the sidebar. Kinda defeats the purpose of Gutenberg, but at least it’s more native than Flexible Content blocks.

  • +1

    Would be nice to add advanced options in the sidebar, to stay true to native WP styling as much as possible.

  • Cheers NickDA, that put me at ease a little bit.

    Our front-end is really fast and optimised with WP Rocket. Theme, except the database, is very lean as well.

    Couldn’t you create a custom WP json for a search function? I do understand it will slow down the default WP Search, but for us that’s not an issue for this website.

    We’ll keep going this route, perhaps update server when we feel like the DB starts slowing down.

  • I don’t think the plugin works (properly?) for flexible content.

    We make heavy use of flexible content, they are called “flexible_content_”. Under those we have ‘content blocks’ that make up the content, but many of those content block fields can be/are empty.

    So querying all “flexible_content” resulted in 250.000+ results, however they are almost all classified as Orphans, when they’re not and still being used on many active pages. Barely any resulted in ‘Empty’.

    Testing and deleting the orphans resulted in many of the content being deleted (test environment, no problem).

    It’s also a multisite but I doubt that is the issue, the plugin successfully identifies the table and prefixes.

  • +1 for this feature. One of the biggest issues I’m running into with ACF is a bloated database at the moment, for this reason but also tons of empty entries being saved to the DB.

  • Update: After testing on a staging environment, I noticed that using a Clone field within Flexible Content causes issues. Not the error perse, but it starts incorrectly showing the fields content on the front-end.

    This is of course related to translating with WPML, it works fine without WPML.

    Any workaround for this? Suggestions?

  • Recently got this problem installing WPML on a ACF heavy site. From reading this topic, it seems to mess up primarily with Repeater Fields/Flexible content?

    Any way to solve this yet?

  • I must say +1 to finding a solution to this.

    I rely heavily on flexible content ‘blocks’, in which each page can be customized heavily. Each block has a clone of ‘advanced settings’, which is then loaded for each flexible content block. It very quickly adds to loading and saving times.

    I’d love to make more complex flexible content blocks for my projects, but I feel myself limiting options as to make it more lean. Not for the front-end, I take care of that obviously, but simply for backend loading.

    Any kind of lazyload (setting), or only saving fields that have been edited would be a great addition to ACF, and open up a new range of possibilities for many of us.

  • Thanks John,

    The empty $value returns bool(false).

    I currently use the following which seems to work:

    // Add pre-populated Repeater Fields
    function my_acf_load_value($value, $post_id, $field) {
      
      if ($value !== FALSE) {
        return $value;
      }
      $value = array(
        array(
          'field_5e8317693aa96' => 'Production',
        ),
        array(
          'field_5e8317693aa96' => 'Director',
        ),
        array(
          'field_5e8317693aa96' => 'Author',
        ),
        array(
          'field_5e8317693aa96' => 'Artist',
        ),
        array(
          'field_5e8317693aa96' => 'Etc'
        )
      );
      return $value;
    
    }
    add_filter('acf/load_value/name=team', 'my_acf_load_value', 1, 3);

    Thanks a bunch!

  • Hi John,

    I’ve tried this on a fresh install and it doesn’t work either.

    • When I comment out if if ($value !== NULL) it at least gets to the $value array. If I don’t, it always seems to return NULL.
    • The $value array runs, but only creates a repeater for each array (2 in the example) but the fields themselves are empty.
    • Var dump returns array(2) { [0]=> array(2) { ["title"]=> string(10) "Production" ["member"]=> string(7) "Testone" } [1]=> array(2) { ["title"]=> string(6) "Artist" ["member"]=> string(7) "Testtwo" } }

    Thank you for your efforts so far!

  • No worries, my bashing my head was before your solution popped up 🙂

    I’m not too familiar with PHP and arrays/objects, so the solution was indeed to realise if I was working with arrays or objects, or objects inside arrays.

    Thanks for helping out!

  • Hi @speakincode, thank you for your help!

    I’ve been bashing my head at it for hours yesterday. Your code throws a fatal error:

    Fatal error: Uncaught Error: Cannot use object of type WP_Term as array in ...

    What eventually seemed to work was this. Don’t know if it’s very elegant PHP…

    $directorArray = $team['Director'];
    $commaArray = $director->name;
    $commaArray = array();
    foreach ($directorArray as $director){ 
        $commaArray[] = '<span>'.$director->name.'</span>';
    }
    echo implode( ', ', $commaArray );
  • Hi John,

    Unfortunately both options did nothing to the fields.

    Adding some echo text in between the function makes it seem like it’s not running at all? Any other way to test this?

    Thanks!

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