How to split embed post title

Good day,

I’m currently using a hidden field with the embed post title option to display a vehicle name.

I now need to be able to split the name in two dynamically. For example, if the vehicle is a Mercedes C-class, I’m currently sending the data through in a hidden field as Mercedes C-Class under the hidden field vehicle type.

But in order for our system to report correctly, I need to send the data through as Brand: Mercedes, Model: C-class. Both as hidden fields and they need to be populated using the title to ensure the information is correct.

Thank you!
Kind regards

Hi Logan,

If you have those two values as two separate custom fields in the post, you can use the {custom_field} merge tag to populate two separate hidden fields for Brand and Model:

ie, {custom_field:brand} and {custom_field:model}

Then you could reasonably configure the title (if you also needed to populate it) as {custom_field:brand} {custom_field:model}

Hi Jim,

Thank you for your reply.

Unfortunately, I don’t have these as custom fields. I do however have Brand/make as the Parent category and the model as a sub-category.

Can I embed categories and subcategories? or can I use the URL somehow?

Thanks

Hi Logan,

In that type of situation, you’re going to need to use the ‘hook method’ for Dynamic Population of those fields.

You’ll also want to take a look at the documentation for gform_field_value_parameter_name and the documentation for Dynamically Populating the Post Author.

As far as grabbing the categories/sub categories from the post, you’ll need to look at the WordPress Core documentation for those particular functions.

Hi Jim,

Thanks for your reply. I’ll read through this and see if I can get it figured out.

Kind regards

1 Like