• Resolved epleuralis

    (@epleuralis)


    I’d like to print the copy contained in the body or the “short description” of the download post when the download link is printed using the downloads shortcode. Do you have a sample template or advise on how to call that variable in the template? Thanks!

    • This topic was modified 6 years, 10 months ago by epleuralis.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey @epleuralis,

    The best way to do this is to add a new template file in which you add this yourself. After you’ve added a new template file, you can tell the [downloads] shortcode to use it with the template attribute. For example: [downloads template="my-new-template"].

    In the new template file a variable $dlm_download will be available which will be the current download. You can use the method get_description() for the description/content of the download.

    More information on content templates: https://www.download-monitor.com/kb/content-templates/
    More information on overriding content templates: https://www.download-monitor.com/kb/overriding-content-templates/

    Kind Regards,

    Barry Kooij

    Thread Starter epleuralis

    (@epleuralis)

    Thanks! I’m not sure if I did this exactly right but it worked. Here’s the template.

    <?php
    /**
     * Shows title and the description.
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    } // Exit if accessed directly
    
    /** @var DLM_Download $dlm_download */
    ?>
    <a class="download-link" title="<?php if ( $dlm_download->get_version()->has_version_number() ) {
    	printf( __( 'Version %s', 'download-monitor' ), $dlm_download->get_version()->get_version_number() );
    } ?>" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
    	<?php $dlm_download->the_title(); ?></a> <?php printf( _n( 'none', '%s', $dlm_download->get_description(), 'download-monitor' ), $dlm_download->get_description() ) ?>
    

    That looks good. Did you place that template in your theme folder? That way it will stay there after you updated the plugin!

    How to set the name of file
    For instance wp-content/themes/childtheme/download-monitor/my-new-template.php
    Is this correct?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding Download Body Copy or Short Description to a template’ is closed to new replies.