Performance: Displaying custom field data
MEDIUM IMPACT
This affects page load speed and rendering performance by how custom field data is retrieved and displayed in WordPress templates.
<?php $custom_fields = get_post_custom(get_the_ID()); echo $custom_fields['custom_field'][0] ?? ''; ?>
<?php echo get_post_meta(get_the_ID(), 'custom_field', true); ?>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple get_post_meta calls per post | Low | Low | Low | [X] Bad |
| Single get_post_custom call per post | Low | Low | Low | [OK] Good |