Title: Shortcode Possibility
Last modified: June 10, 2024

---

# Shortcode Possibility

 *  Resolved [Demian](https://wordpress.org/support/users/demian85/)
 * (@demian85)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/)
 * Hi,
 * Is there a shortcode integrated? This would be a simple straight forward approach.
 * Demian

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [mrwweb](https://wordpress.org/support/users/mrwweb/)
 * (@mrwweb)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/#post-17814756)
 * [@demian85](https://wordpress.org/support/users/demian85/) Can you say more about
   how you’d use a shortcode?
 * This is 100% untested, but this _might_ work (in `functions.php` or an `mu-plugin`)
   if you place the shortcode in a template that is on a post type archive screen:
 * `add_shortcode( 'ptad_description', 'ptad_get_post_type_description' );`
 * You’d then use `[ptad_description]` where you want the description.
 * Use at your own risk, and make sure you know how to remove the code if you try
   it out.
 *  Thread Starter [Demian](https://wordpress.org/support/users/demian85/)
 * (@demian85)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/#post-17816051)
 * Hi [@mrwweb](https://wordpress.org/support/users/mrwweb/)
 * Thanks for the quick reply. We have around 8 different CPTs, they use an archive
   template and I would like to return that post type description into the template.
 * I am comfortable with coding, so no worries. However, the approach for the short
   code does not return anything unfortunately.
 *  Plugin Author [mrwweb](https://wordpress.org/support/users/mrwweb/)
 * (@mrwweb)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/#post-17817862)
 * [@demian85](https://wordpress.org/support/users/demian85/) If you have access
   to the template, then you shouldn’t need a shortcode. Putting `the_archive_description()`
   into your template should show the description. If not, then there’s probably
   an issue with the theme or a plugin messing up the page’s query so that function
   doesn’t work.
 *  Thread Starter [Demian](https://wordpress.org/support/users/demian85/)
 * (@demian85)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/#post-17819079)
 * Hi!
 * I notice you work from the point of view to build pages based on its php template
   files. But 90% of the wordpress sites are using frontend page builders like wpbakery,
   elementor or gutenberg. So a shortcode should just also work there. If you have
   a prof. Theme, amending archive.php is not part of wordpress anymore unfortunately
   😉
    -  This reply was modified 1 year, 11 months ago by [Demian](https://wordpress.org/support/users/demian85/).
 *  Thread Starter [Demian](https://wordpress.org/support/users/demian85/)
 * (@demian85)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/#post-17819128)
 * To give an example. We use the CPT UI plugin to generate post types. They also
   have a field for post type descriptions, unfortunately not a user friendly input
   field. But if I use a custom function to project it into the frontend template
   it works:
 *     ```wp-block-code
       function custom_output_cpt_description_shortcode() {    echo get_the_post_type_description();}add_shortcode( 'post_type_description', 'custom_output_cpt_description_shortcode' );
       ```
   
 *  Thread Starter [Demian](https://wordpress.org/support/users/demian85/)
 * (@demian85)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/#post-17819182)
 * It seems that $post_type returns into an empty string from the plugin. I also
   get this warning:
 *     ```wp-block-code
       PHP Warning: array_key_exists(): The first argument should be either a string or an integer in /wp-content/plugins/post-type-archive-descriptions/inc/template-tags.php on line 36
       ```
   
 * Not sure if $post_type is properly defined.
 *  Plugin Author [mrwweb](https://wordpress.org/support/users/mrwweb/)
 * (@mrwweb)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/#post-17820906)
 * > We use the CPT UI plugin to generate post types. They also have a field for
   > post type descriptions, unfortunately not a user friendly input field. But 
   > if I use a custom function to project it into the frontend template it works
 * It sounds like there may be some confusion around how this plugin works. This
   does not display the `description` attribute of the post_type object, but rather
   creates a custom setting and editor for writing a description for each post type.
   You can see that editor and menu location in the plugin’s screenshots.
 * If you use either `the_archive_description` or `get_the_archive_description` 
   in your template, then the plugin filters the result and displays the _custom_
   description you’ve edited.
 * >     ```wp-block-code
   >      echo get_the_post_type_description();
   >     ```
   > 
 * Note that shortcode functions should always `return` their contents and not `
   echo` it.
 * >     ```wp-block-code
   >     PHP Warning: array_key_exists(): The first argument should be either a string or an integer
   >     ```
   > 
 * I tested that shortcode and it didn’t work. This was the error that resulted.
   This works instead:
 * `add_shortcode( 'archive_description', 'get_the_archive_description' );`
 * > I notice you work from the point of view to build pages based on its php template
   > files. But 90% of the wordpress sites are using frontend page builders like
   > wpbakery, elementor or gutenberg. So a shortcode should just also work there.
   > If you have a prof. Theme, amending archive.php is not part of wordpress anymore
   > unfortunately
 * This will work on any theme that supports the built-in archive description function
   that’s core to WordPress.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Shortcode Possibility’ is closed to new replies.

 * ![](https://ps.w.org/post-type-archive-descriptions/assets/icon.svg?rev=2981804)
 * [Post Type Archive Descriptions](https://wordpress.org/plugins/post-type-archive-descriptions/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-type-archive-descriptions/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-type-archive-descriptions/)
 * [Active Topics](https://wordpress.org/support/plugin/post-type-archive-descriptions/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-type-archive-descriptions/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-type-archive-descriptions/reviews/)

## Tags

 * [Short Code](https://wordpress.org/support/topic-tag/short-code/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 7 replies
 * 2 participants
 * Last reply from: [mrwweb](https://wordpress.org/support/users/mrwweb/)
 * Last activity: [1 year, 11 months ago](https://wordpress.org/support/topic/shortcode-possibility-2/#post-17820906)
 * Status: resolved