Archived topic
Displaying custom fields in single posts
5 replies · Started by Robert on February 28, 2022
Hi there,
Do we need to edit the single.php in order to display custom field values in single posts meta?
We've set up 2 custom fields using the native WP custom fields.
We've then tried with a heading and button to get the dynamic content into a block.
But the values are not displaying with either.
Are there any step-by-step instructions anywhere for this?
Many thanks
Hi Robert,
This should be possible without editing any files.
Kindly see: https://share.getcloudapp.com/kpu4XvkL
Also see: https://share.getcloudapp.com/DOumb1gB
Here it is working: https://share.getcloudapp.com/o0uZWAjz/annotate
As shown, I created a custom field for Posts, and then hooked a Headline Element which dynamically grabs the custom field “testfield”.
Moreover, you may also add it through a Hook Element.
Unfortunately, we have no step by step guide with regards to this but here is an article by ACF which may assist: https://www.advancedcustomfields.com/resources/displaying-custom-field-values-in-your-theme/
Then, as mentioned, you may use a Hook Element to make it appear in your preferred location. :)
Also see: https://docs.generatepress.com/article/hooks-element-overview/
Hope this helps! :)
Hi Fernando,
Many thanks for your lightning fast and very helpful reply - much appreciated.
So it works for us using ACF but not with the native WP.
Does ACF slow down pageloads, would you know?
Thanks again.
You’re welcome Robert! Glad to be of assistance! :)
With regards to ACF, it shouldn’t have a significant impact to page’s loading speed.
See this for reference: https://support.advancedcustomfields.com/forums/topic/does-this-plugin-slow-down-my-website/#:~:text=It%20does%20not%2C%20or%20at%20least%20it%20does%20not%20significantly%20impact%20page%20load%20time.
Hope this clarifies! :)
Hi Fernando,
Thanks for the links - all looks good then.
Excellent support - much appreciated.
You’re welcome Robert! Thank you for the compliment! We appreciate it too! Feel free to reach out anytime if you’ll need assistance with anything else. :)