Skip Navigation

[Resolved] How can I create a custom field with html code?

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

This topic contains 1 reply, has 2 voices.

Last updated by Christopher Amirian 2 years, 9 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2608261

I'm trying to create a directory site with a list of ministry partners. These ministry partners need to embed their donation form, which is done with an HTML code that's unique to them. We already have our partners setup on an old website using posts, so we'd like to continue using posts rather than creating a custom post type. what field do I use to make that happen?

#2608589

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

If you want to embed unique HTML codes for each ministry partner in your WordPress posts, you can do this by using Toolset custom fields.

Here is how you could achieve this using Toolset:

- Navigate to your WordPress dashboard, find "Toolset" on the sidebar, and click on "Custom Fields."
- Click on the "Add New" button to create a new field group.
- Name this group something like "Partner Information" and select "Posts" in the "Where to include this Field Group" section.
- Add a new field to the group by clicking on "Add New Field." In your case, the new field would be something like "Donation Form Embed Code." For the field type, select "Single Line" if the HTML code can fit in one line or "Multi-line" if the HTML code is longer.
- Save your changes.

For more information:

https://toolset.com/course-lesson/creating-custom-fields/

To display the custom fields on the single post items, you either can use the Toolset Blocks by creating a template for a single post following the steps below:

https://toolset.com/course-lesson/creating-templates-to-display-custom-posts/

Or, if you do not want to lose the single post template that you have already in our theme, you'd have to edit your theme's single post template. Insert the following PHP code where you'd like the form to appear:

<?php echo get_post_meta(get_the_ID(), 'wpcf-donation-form-embed-code', true); ?>

Replace 'wpcf-donation-form-embed-code' with the slug of your custom field.


Please note that this method requires some understanding of PHP and how WordPress themes work

Remember that inserting arbitrary HTML code into posts might pose a security risk, especially if multiple people can edit posts. Make sure to only insert trusted HTML code to prevent cross-site scripting (XSS) attacks and other security issues.

For more information:

https://toolset.com/course-lesson/limitations-on-html-content-in-custom-fields/