Home › Forums › Front-end Issues › Optimize code to query Custom Fields as PHP memory limit error? › Reply To: Optimize code to query Custom Fields as PHP memory limit error?
Hi @caram
You could better optimize the code by making use of the get_field
function instead of the get_post_meta function. This will allow ACF to cache data and only load it once (instead of twice in your case):
<?php if( get_field('yyy') ) { ?>
<span class="info-detail"><?php the_field('yyyy'); ?></span>
<?php } ?>
This said, your code should not be maxing out memory limits, so it’s more likely to be a ‘too many plugins / functionality’ issue. Perhaps a server upgrade is needed or you can remove some plugins / functionality.
Thanks
E
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.