Advanced Custom Fields – get_field function slow to load Flexible Layout data
I’ve created a flexible content field type which inside has just 4 layouts, and each layout only contains a handful of other fields too. I’ve used this same setup on other sites without issue, however for no reason it’s now taking 23 seconds minimum to load.
As a test I am not even displaying the content but instead doing a var_dump
of the get_field
data and that is still taking 23 seconds. All other pages are working fine and load in normal timeframes (2-3 seconds).
I’m doing my debug on plain empty page, no other content other than header/footer, I’ve also tried in multiple other page templates too.
Query Monitor: I’ve already got this installed and it shows no clear indicators of issues, no slow query reports etc, see screenshot. My question is, how best to debug this slow issue?
Plugin: Advanced Custom Fields PRO
Version 5.8.9
My debug code:
$content_blocks = get_field('content_blocks');
var_dump($content_blocks);
The var_dump output:
array (size=4)
0 =>
array (size=2)
'acf_fc_layout' => string 'double_banner' (length=13)
'panel' =>
array (size=2)
0 =>
array (size=5)
...
1 =>
array (size=5)
...
1 =>
array (size=7)
'acf_fc_layout' => string 'top_picks' (length=9)
'heading' => string 'Top Picks' (length=9)
'cta_text' => string 'View All Products' (length=17)
'cta_link' => string 'https://dev.testdomain.co.uk/shop/' (length=38)
'product_ids' =>
array (size=5)
0 => int 806
1 => int 854
2 => int 850
3 => int 846
4 => int 890
'posts_per_page_mobile' => string '' (length=0)
'posts_per_page_desktop' => string '' (length=0)
2 =>
array (size=7)
'acf_fc_layout' => string 'platforms_list' (length=14)
'heading' => string 'Find products by Marketplace' (length=28)
'cta_text' => string 'View All Products' (length=17)
'cta_link' => string 'https://dev.testdomain.co.uk/shop/' (length=38)
'platform_list' =>
array (size=5)
0 =>
array (size=4)
...
1 =>
array (size=4)
...
2 =>
array (size=4)
...
3 =>
array (size=4)
...
4 =>
array (size=4)
...
'posts_per_page_mobile' => string '' (length=0)
'posts_per_page_desktop' => string '' (length=0)
3 =>
array (size=7)
'acf_fc_layout' => string 'custom_blocks' (length=13)
'heading' => string 'Categories' (length=10)
'cta_text' => string 'View All Products' (length=17)
'cta_link' => string '/shop' (length=5)
'blocks' =>
array (size=6)
0 =>
array (size=3)
...
1 =>
array (size=3)
...
2 =>
array (size=3)
...
3 =>
array (size=3)
...
4 =>
array (size=3)
...
5 =>
array (size=3)
...
'posts_per_page_mobile' => string '' (length=0)
'posts_per_page_desktop' => string '' (length=0)
I have no idea how to debug this further.
Leave an answer