Include CPT Category Description [RESOLVED]

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.


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.


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?


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 :blush:


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 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?