Title: Using PHP in template files
Last modified: February 11, 2020

---

# Using PHP in template files

 *  Resolved [gefahr](https://wordpress.org/support/users/gefahr/)
 * (@gefahr)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-php-in-template-files/)
 * Hi,
 * I copied the template file “link-template-default.php” to my child theme to customize
   the displayed content as described in the documentation. This works great until
   I try to use PHP in this file. All the PHP I add in the file gets commented out
   before it’s rendered.
 * Is there a way to use PHP in those template files?
 * Thank you!

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

 *  Plugin Author [Shahjada](https://wordpress.org/support/users/codename065/)
 * (@codename065)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-php-in-template-files/#post-12424608)
 * Hi,
    You can’t use php code in link/page template, you can only use template 
   tags, doc: [https://www.wpdownloadmanager.com/doc/templates/template-tags/](https://www.wpdownloadmanager.com/doc/templates/template-tags/),
   however, if you need to use custom php code, you need to write a function with
   the code and convert it into a template tag, please follow the doc: [https://www.wpdownloadmanager.com/doc/filter-reference/wdm_before_fetch_template/](https://www.wpdownloadmanager.com/doc/filter-reference/wdm_before_fetch_template/)
 *  Thread Starter [gefahr](https://wordpress.org/support/users/gefahr/)
 * (@gefahr)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/using-php-in-template-files/#post-12425808)
 * Thanks Shahjada! I did not know I can create custom template tags.

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

The topic ‘Using PHP in template files’ is closed to new replies.

 * ![](https://ps.w.org/download-manager/assets/icon-256x256.png?rev=1561688)
 * [Download Manager](https://wordpress.org/plugins/download-manager/)
 * [Support Threads](https://wordpress.org/support/plugin/download-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/download-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/download-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/download-manager/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 2 replies
 * 2 participants
 * Last reply from: [gefahr](https://wordpress.org/support/users/gefahr/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/using-php-in-template-files/#post-12425808)
 * Status: resolved