Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
209 views
in Technique[技术] by (71.8m points)

php - Wordpress, Cache advanced custom fields or maybe other solution?

After having a hard time figuring out what plugin in my WordPress site causes a low page load speed, this happens to be the most important plugin ACF (advanced custom fields Pro).

But I think I know the reason, I created a theme on my own that feet my needs, however in this theme the post loop load few ACF fields (and I just have to do that unfortunately ), the fields are loaded with the basic call function get_field(), but probably because this fields are inside the loop this causes a long load time ( extremely high, this actually add a entire 4 seconds the load time!!).

I am a developer but I am not professional one but as much as I understand this happens because each time the function get_field() calls a query and that makes the long page load time, so I figured out that maybe there is a way to cache all the fields that I need before the loop so it won't take so much time to load? Or maybe there is much better solution that I can't think about? Seriously any ideas are welcome, because I am stuck and hoping there someone here with a fresh idea.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm not familiar with the ACF plugin, but it seems that you are very sure that this is causing the issue. By default, custom fields should not impact performance, whether you have one or one thousand. See this post I have done on the issue of custom fields

I would sugget that download and install a plugin like Query Monitor which prints all the relevant info to screen about the amount of db calls and the time taken for each db call. Just a note, don't run this on a production site. Do this on a local test install or put your site on maintance mode. You don't want your users being dished up with pages of query info that will not make sense to them :-). As I said, the plugin prints the information straight to the screen


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...