We have added 2 custom fields to our post posts using ACF. We are now trying to display them on the post pages using “Single External Shortcode” shown by Bettina in the post below, but the data is not showing.
Single External Shortcode - content
[acf field="source_domain"]
Is there something else that is needed to do to activate the shortcode?
Hi EamonnO,
Can you please let us know how you set the ACF and how you set the shortcode in single post template.
Did you take the right parameter for shortcode ? -> https://i.imgur.com/Zls1gii.png -> https://www.advancedcustomfields.com/resources/shortcode/
Thank you!
Hello Calin,
Thanks for your response. Let me explain my setup.
I am using these:
- WordPress Automatic Plugin – to get RSS news feeds and post them on my site.
- Advanced Custom Fields – to add 2 fields to the posts “source_domain” & “source_link”
- TagDiv Newspaper theme 11 – to display everything.
So after more testing, I have discovered 2 issues.
When I edit a post, I can see the correct data being put into the Custom fields by Automatic.
See these screenshots of the ACF setup, Automatic setup, and Edit Post page.
- ACF setup and shortcode names https://imgur.com/a/Bu7QKdY
- Automatic plugin settings to transfer values to Custom Fields https://imgur.com/a/IGq3XhI
- Custom fields, populated by automatic, visible on “Edit Post” page https://imgur.com/a/derrTxm
By messing around I have discovered that the text in the source_domain field will only display if I manually edit it using the post editor. I only have to make a small change like deleting and re-entering the last ‘m’ of the source domain.
See these screenshot.
- Post without manual interventions Custom field values do not show. https://imgur.com/a/amzHeBr
- Post if source_domain Custom field is entered or changed manually then they show.
https://imgur.com/a/Ql4njFm
Can you replicate this bug? Any ideas on how to fix this?
Also, the “source_link” data only show when the “source_domain” is either empty or “cleaned” as described above. Furthermore, I can display the “source_link” data but I cannot generate a link.
This is the code I’m using to create a link
< #a# href=" [acf field="source_link"] "> Read more
Thank you
Hi,
I made some tests but I used only the Advanced Custom Fields, but today I will test with WordPress Automatic Plugin too and I will let you know the results.
But if you only want to display the source of the post and this to be clickable, then I think that you can use the theme options for posts -> https://i.imgur.com/IT6TNrA.png
For Read more if the code is set like this
https://i.imgur.com/gcVBWlS.png
then should be working and the Read more should be clickable if there is assigned the link.
Thank you!
Hi Calin,
I have done some more testing, here is what I did and what I found.
Test Environment – new WordPress install
Theme & Plugin
- TagDiv Newspaper theme 11
- Advanced Custom Fields
– to add two text fields to the posts “source_domain” & “source_link” both text fields. - FakerPress – to add test posts.
Test process
- used FakerPress to create 5 test posts. These posts do not contain any data in the ACF fields.added ACF field data to 2 posts via WP post editor.
- added ACF field data to the remaining 3 posts directly to the WP Database _postmeta table using phpMyAdmin.checked all posts via WP post editor to confirm ACF field data was correctly inserted.
- updated 1 of the 3 direct entry posts using WP post editor.
Conclusion.
Viewing the posts using the TagDiv Newspaper theme 11 and displaying the ACF field data, in the post template as as described using [acf field=”source_domain”] I saw:
- first 2 posts, created using the WP post editor – displayed the ACF field data correctly.
- next 2 posts, where ACF field data were entered directly into the database did NOT show any ACF field data.
- last post where ACF field data was entered directly into the database, then post updated using WP post editor- displayed the ACF field data correctly.
So it seems that the theme will only show the ACF field data if the post has been entered or updated via the WP post editor. This is very frustrating as it means that other plugins that enter data directly into the database do not work as intended.
Additionally, when tested with Elementor and a basic WP theme using PHP it works fine.
Have you placed a hook on the WP post editor, to update a cache or something similar?
Help!
Hi,
I do not think the problem is with the cache, if it was from it, then the post would no longer appear, nut just the AFC data.
As far as I know there is no hook on WP post editor, but there may be some conditions related to the publish/update button from the WP posts.
Thank you!