Starting with Download Monitor 5.1.16, the Short Description (excerpt) field is no longer shown on the Download edit screen. Most of the default templates don’t use it, so we removed it to keep the edit screen simpler.
If you use the short description in your own custom template or layout, for example to show a short summary under each file in a list, you can bring the field back with a small piece of code. This guide shows you how to do that, step by step. You don’t need to know how to code.
Before you start
-
Your existing short descriptions are safe. Removing the field didn’t delete anything. Short descriptions you added before are still saved and still show up on your website. Only the box you type them into is hidden.
-
Make a backup. It’s always a good idea to back up your website before you add code to it.
-
Choose one method only. Below are two ways to add the code. Use Method 1 or Method 2, not both.
The code
This is the code you will need, whichever method you choose. Copy all of it:
add_action( 'add_meta_boxes_dlm_download', function () {
add_meta_box( 'postexcerpt', __( 'Short Description', 'download-monitor' ), 'post_excerpt_meta_box', 'dlm_download', 'normal', 'high' );
}, 99 );It adds a box called Short Description back to the Download edit screen. WordPress saves whatever you type in it automatically, so you don’t need anything else.
Method 1: Using a code snippets plugin (recommended)
This is the easiest and safest way. A code snippets plugin lets you add small pieces of code from your WordPress dashboard. The code keeps working when you update or change your theme.
-
Install a code snippets plugin
In your dashboard, go to Plugins > Add New and search for “code snippets”. Install and activate any well-rated plugin that lets you add PHP snippets. If you already have one, skip this step.
-
Add a new snippet
Open the snippets plugin from your dashboard menu and click the button to add a new snippet. Give it a name you’ll recognize later, for example Download Monitor – Short Description.
-
Set the snippet type to PHP
If the plugin asks for a code type, choose PHP. Don’t choose HTML, CSS or JavaScript.
-
Paste the code
Paste the code from above into the code area. If the code area already has
<?phpwritten at the top, leave it there and paste the code below it. Don’t add a second<?php. -
Choose where the snippet runs
If the plugin asks where the snippet should run, choose Only run in administration area (or Run everywhere, if that option isn’t available).
-
Save and activate
Click Save and Activate, or save the snippet and turn it on. That’s it.
Method 2: Using your theme’s functions.php file
Use this method if you don’t want to install another plugin. It needs a bit more care.
Important: If you add the code to your main theme, it will be lost the next time the theme updates. To avoid this, use a child theme. If you aren’t sure whether you have a child theme, use Method 1 instead.
-
Open the theme file editor
In your dashboard, go to Appearance > Theme File Editor. On some websites it’s under Tools > Theme File Editor. You can also edit the file through FTP or your hosting’s file manager. It’s in
wp-content/themes/your-theme/functions.php. -
Select the right theme
In the top right corner, check that the selected theme is your active theme (preferably your child theme).
-
Open functions.php
In the file list on the right, click Theme Functions (functions.php).
-
Paste the code at the very end
Scroll to the bottom of the file and paste the code on a new line after everything else. If the file ends with
?>, paste the code before that?>. -
Save
Click Update File. If WordPress shows an error and doesn’t save the file, check that you copied the whole code and pasted it in the right place.
Check that it works
-
Go to Downloads > All Downloads and edit any download, or add a new one.
-
Look for the Short Description box below the main content area. Any short description you added before will already be in it.
-
Type or edit the text, then click Update (or Publish) to save it.
Can’t see the box? Click Screen Options in the top right corner of the edit screen and make sure Short Description is checked.
Showing the short description on your website
If your custom template already shows the short description, you don’t need to do anything else. If you want to show it somewhere else, you can use this shortcode, replacing 123 with the ID of your download:
[download_data id="123" data="short_description"]Developers can also use $dlm_download->the_excerpt() inside a custom download template.
Removing the field again
If you don’t need the field anymore, deactivate or delete the snippet (Method 1), or remove the code from your functions.php file (Method 2). Your saved short descriptions won’t be deleted.
