I have a form on all posts, but want to showcase a field depending on the post category.
You can use the merge tags in gravity forms to receive the post details, e.g. {embed_post:post_title} will receive the post title.
I have tried the following but cannot receive the current post category:-
{embed_post:post_category}
{embed_post:post_selected_category}
Could anyone please offer a suggestion?
Thank you
2
Answers
Unfortunately, Gravity Forms merge tags do not have a direct option for post category.
You can achieve this by creating a custom shortcode or using functions.php to fetch the post category and conditionally render the field. You would retrieve the post category within your WordPress loop using ‘get_the_category()‘ or a similar function, then use logic to decide when to display the specific Gravity Forms field based on the category.
Additionally, make sure to add proper error handling and checks to ensure the field displays correctly for each category.
GF Populate Anything can be used to populate a field with the embed post’s category. Here’s an example: