This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
I am trying to: use custom fields created with Toolset as snippet variables in Yoast (WP SEO). This is possible with WP custom fields as described in the following link:
Is this possible with Toolset custom fields?
I don't think debug info is relevant in this case, but I've included it just in case.
Thank you for contacting us and I'll be happy to assist.
As explained in the link that you've shared ( hidden link ), simple custom fields like a single line type can be used directly in snippet variables, in this format:
For example, if you have a Toolset custom field with the slug "book-info", it can be used like this:
Note: By default, Toolset custom fields are saved with a "wpcf-" prefix appended to their slugs.
For other complex type custom fields like radio buttons, checkboxes, etc, you can register a custom template variable ( refer to the section "Registering a custom template variable" from that same link that you shared ).
Note: To get the Toolset custom field values in your custom code, you can use "Types Fields API":
I hope this helps and for personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
Hi, thanks for your reply.
I have tried your suggestion but can't get it to work. I'm using a simple, single line text field. Here are some screenshots. What am I doing wrong?
PS - I'm using the Toolset Types plugin, so I assume I DO NOT need to edit my functions.php file as described in the link you sent (https://toolset.com/documentation/customizing-sites-using-php/functions/). Is that correct?
Thanks for writing back.
The field with the same slug works as expected on my test website:
Screenshot - Custom field setting:
Screenshot - Custom field value:
Screenshot - Custom field in the snippet preview:
I'll recommend testing this with all extra plugins (other than Toolset and Yoast SEO) disabled and with a default theme like Twenty Nineteen. This will help in narrowing down to a possible conflict.
Any custom PHP code that you need to execute on your website can be added into either the active theme's "functions.php" file or Toolset's own custom code section, as explained in this guide:
Thanks for testing.
I'm still not clear about whether or not I need to add Toolset custom field values into my custom code.
Did you have to modify your php files (as described here) for it to work in your test?
Did you add this code?
<!--?php echo(types_render_field( 'wpcf-job-title', array( 'arg1' => 'val1', 'arg2' => 'val2' ) )); ?-->
I apologize if my mentioning of custom code resulted in confusion.
Let me clarify this further. My earlier message can be divided into two parts, as shown in this screenshot:
For part 1, where you just need to use a Toolset custom field's value, which is a simple "single line" type field, no custom code changes will be needed and the format %%cf_<custom-field-name>%% works inside the Yoast SEO's snippet preview section.
The screenshots from my last message confirm this as I didn't include any custom code for this testing.
The custom code will be needed for part 2, where you need to use a value from Toolset custom field which stores data in a complex way, for example, the radio buttons, checkbox or checkboxes type fields. If you only need values from "single line" type custom fields, you won't need any custom code.
I hope this clarifies and please let me know if you need any further assistance around this.
OK. This seems to be working (sort of). It does not populate the snippet immediately. I have to save the post and then re-open it to see the change. Is this how it worked in your test?
Thanks for the update and glad that it works.
On my test website, the snippet preview updates with the value of the custom field immediately/on the fly, without having to save or update the post.
( screencast: hidden link )
Can you please check your browser's console for any script errors or warnings?
The dynamic content changes/updates can be affected if there are any script errors or warnings.