Skip Navigation

[Resolved] show the cpt description on an archive page

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by johnh-18 2 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#2180399

For each cpt archive page, I would like to include the cpt description below the archive title.

Is there any documentation that you are following?
I have tried the following old cases but none of them has worked.
https://toolset.com/forums/topic/how-show-custom-post-type-description-in-frontend/
https://toolset.com/forums/topic/custom-post-type-description/#post-374182
Is there a similar example that we can see?

What is the link to your site?
hidden link
It is a dev site so you need the following details for access
user: janne
pw: Lvt@1527

Best regards / jan

#2180651

Hi,

Thank you for contacting us and I'd be happy to assist.

I was able to make the code from Minesh's reply work, after slight adjustment.
( ref: https://toolset.com/forums/topic/custom-post-type-description/#post-374182 )


function get_post_desc( $atts,$content ) {
	global $wp_post_types;
	global $WP_Views;

	$post_type = $WP_Views->post_query->query['post_type'];

	$obj = $wp_post_types[$post_type];

	return $obj->description;
}
add_shortcode( 'get_cpt_desc', 'get_post_desc' );

Next, I added some description text, in the "Books" CPT settings on my test website.
( screenshot: hidden link )

And in the WordPress Archive for the Books CPT, I included the shortcode like this:


[get_cpt_desc]

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2180775

Hi Waqar,
Many thanks for superfast response. And it works perfectly.
Have a nice week.
Best regards / jan

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.