Hi all,
I have a very simple form that is place on my custom post type template. What I would like to do is include the CPT category description in the email notification that comes through.
I appreciate any help.
Thanks
Lee
Hi all,
I have a very simple form that is place on my custom post type template. What I would like to do is include the CPT category description in the email notification that comes through.
I appreciate any help.
Thanks
Lee
Hi Lee. Are you embedding the form with the function call in the CPT template? Or adding the form some other way to all your CPTs?
Hi Chris,
Iâm using the following in my template file:
<?php gravity_form( 2, false, false, false, '', false ); ?>
I hope this helps, let me know if you need further information.
Thanks
Lee
Hi Chris,
Did the info provided give a better overview of my setup? Any help would be greatly appreciated.
Many thanks
Hi Lee. Thanks for the information. You can get the category description in your template file (assuming thatâs the template for the category) using this code with your shortcode:
<?php $cd = category_description(); gravity_form( 2, false, false, false, array('cat_desc' => $cd ), false ); ?>
You will need a single line text field in the form that is set up for dynamic population (on the Advanced Tab) with a dynamic population parameter name cat_desc
. If you modify your shortcode to include the code to get the category, and set up a field for dynamic population as explained, that will populate the field in the form with the category description. Give that a try and let us know how that goes.
Thanks for the replay Chris, I did try that but couldnât get it to work. The page the form is being pulled into is a single template, rather than the category template, might this be why. I also have a taxonomy for the categories that is named ânurseryâ.
I did try changing âcat_descâ in your code above to ânurseryâ but still no joy. I believe I have setup the field correctly since i am using dynamic population on another field.
I think I am so close though, anything obvious that might be causing the field to not populate?
Thanks
That WordPress function will not work unless itâs used in a Category template page. What is the name of your template file? Itâs a template file for pulling in single posts only?
Hi Chris,
It is pulled in to a single post (single-planner.php)
I hope this helps.
Is the post type âplannerâ? And if that is the case, the category description will never change?
Thatâs right, the post type is âplannerâ.
I have setup a taxonomy titled ânurseryâ, for each nursery there is a category description, this is what I am trying to pull into my Gravity Form email notifications.
I have attached a screenshot of the description in the admin area, so for the description I currently have âTrying to pull in this description.â
Apologies Chris, I wasnât clear on key bits of my setup, so:
Post type: planner
Taxonomy: nursery
Each single post from the planner post type has one category (nursery) assigned to it, attached to each category is a description. I am trying to pull out the category description and place in the email notification that comes through from a submitted form on the single-planner.php
I wish Iâd explained it better from the start, apologies, hopefully now clear
I think I understand now. I was just typing my clarification which is basically what you said. Working on a new version for you now.
Youâre a superstar, thanks Chris.
Hi Lee. I thought I had something but then looked back at your screenshots and I donât think itâs correct. Do you have a staging or development site where I can test this with your configuration? If so, I will send you the details on how to give me access to that. Thank you.
Really appreciate the help, sure, I can give you access to the staging site.
Thank you. Please email chris@rocketgenius.com with the URL and username/password for an administrator login on that site and Iâll take a look and make sure what I come up with will do what you want. Thank you.
Thanks Chris, details emailed over.
I have them and I logged in. It looks like these two Nurseries:
ABC Nursery
Leeâs Nursery
Are actually being displayed by the archive-planner.php
template. Hereâs a screenshot:
The archive-description
class comes from this template file:
Iâm not sure what to make of this. Iâm not sure why an archive template is being used for those two nurseries. Do you know? I want to be sure I am editing the correct template.
Hi Chris,
Iâve been working with the âsingle-planner.phpâ file which is used for the page where the form is here: /planner/abc-nursery/2021/
⊠I havenât inc. the full url but you have it.
The GF form is activated by clicking the âRequest your A2 Wall Plannerâ link.
I may have initially created the archive-planner.php but donât plan to have an archive page. So yes, its the single-planner.php page I have been working on.
I hope this helps, do let me know if there is further info required.
I see now with that URL. I see in the source that the template file is single-planner. I will work with that one. That is the page that will have the form where you want the Nursery taxonomy description populating a field in the form?