I have thousands of pages using a CPT I have set-up on the site.
Within this CPT I have created a custom field called ‘Statement’. Within this field, I am using a slightly different shortcode for each page (e.g. [eod_financials target=”AAPL.US” id=”10329343″ preset=”Income Statement” years=”2018-2023″]). The “AAPL.US” section of the share price-related shortcode is the only part that changes.
I have loaded the custom field metadata to the site for each page and am referencing that by using the ‘Custom Field’ attribute and choosing ‘statement’ from the list within Composer, but it is only showing the shortcode text, rather than rendering the actual shortcode.
I know the shortcode works.
What am I doing wrong?
We need to be able to call shortcodes from the Custom Fields. I had assumed that the ACF plugin would do this, but apparently it doesn’t. Its a pretty big gap in the functionality.
For your reference, we are looking at including premium stock information from some data vendors using the Financial Stocks & Crypto Market Data Plugin (https://wordpress.org/plugins/live-stock-prices-for-wordpress/).
To do this, we would create a field and upload the variations of the shortcodes to each of the 10,000 companies we cover.
The shortcodes work perfectly well when adding them statically to a template, but we cannot find a way of adding them dynamically to CPT.
Hello,
Unfortunately, I don’t understand the process by which you want to implement it, i.e. these are the types of custom fields, do you use one from here or not? I need more specific details to understand what you want to achieve.
You can try to use this option and check if it works https://www.advancedcustomfields.com/resources/shortcode/
Thank you!
Easiest way to explain it:
I am using CPT and ACF to create a new post type.
I have then used this new post type for 10,000 posts, with each post featuring information on a seperate company (Microsoft, Apple, Amazon, etc).
Within this post type I want to feature a unique shortcode to display the share price and share history of each company (e.g. Amazon’s share price on the Amazon post).
This equates to creating 10,000 seperate shortcodes and uploading them to the site as a field.
I have done this, but the Custom Field within Composer seemingly will not display the content of the shortcode. It just returns [shortcode] text.
Because of this I need to find an alternative.
Hope this makes more sense!
Further to the conversation, I have found a solution. Worth noting for future development of the template.
I’ve just added the line to the bottom of the functions file:
add_filter(‘acf/format_value/type=textarea’, ‘do_shortcode’);
Whilst this has a drawback re all fields matching ‘textarea’ now doing shortcodes, it does seem to work.
Just a quick update on this:
I have noticed that whilst I can now display the shortcode in a custom field, for some reason it only displays the content of the shortcode when I go into WordPress admin and manually save each post. I don’t have to make any edits. Just save.
Do we have a solution so that I do not have to manually save each and every post?
I have tried Bulk Edit within WordPress Admin, but that doesn’t work.
Thanks in advance.