How to Create A Download Page in WordPress Website Using PHP script

Table of Contents

Hi Dudes, Welcome to Our Guideflare blog, let's see how to create a Download page for WordPress without any plugin. this process is very simple to set up. and very effective and Responsive to create a download page on WordPress.

How to Create A Download Page in WordPress Websites

this is the first article on the setup download page on WordPress and very very useful to All WordPress website Runners. And one more thing on your mind this method is only for the WordPress platform not for bloggers if you want to make a download page on blogger. please check out below link

Checkout:- How to create crypto js safelink download page with timer

we are providing ways to add this download page function on your WordPress theme. Just follow the provided steps in this Article.

If you don't have any knowledge Edit coding on WordPress. do not worry we are perfectly helping to make a download page on your WordPress Blog. So, First, make sure to backup your theme on your WordPress blog for Security purposes.

Please Take Backup of your Wordpress Blog. Guideflare is not Responsible for Any Data loses on your Wordpress Blog.

How to add Download page Function on WordPress Step by Step

Step 1: First of all login your WordPress Admin Dashboard

Step 2: Next, Open the Plugin Section and Add New plugin. that plugin name is Filester - File Manager Pro.

Step 3: Search Filester and Install Now and Activated Filestar - File Manager Pro Plugin.

Download page for Wordpress - File ster installisation

Step 4: Next, open the Filester plugin Dashboard on the WordPress Dashboard. This plugin was work as a File Manager. and Shows All Files on your Website.

Step 5: Now Navigate to the wp-content > themes > generate press. If you using any other theme, you need to navigate to your theme Name on this Step.

Downloadable Files - File manager Section

Step 6: Now you want to create the New Folder on your Theme Folder. Right-click the Cursor and Create the New Folder in the Main Theme Path.

Downloadable link on Download page wp - Create new Folder

Step 7: Give the Name "template" to Newly Created folder.

Download page for Wordpress - Give the Name

Step 8: Now open the Newly created "Template" Folder. and, Right-click the Cursor to Create a New plain text File on the Newly Created Folder.

How to Create Download page for Wp - Create New Plain text File

Step 10: Give the name to "download.php" on the newly created plain text file.

how to create the download page on wordpress - Assign the name the download.php

Step 11: Now you have successfully created the Download page template for WordPress. So, close the File Manager and Come back to WordPress Dashboard.

Step 12: Go to Appearance > Theme File Editor in the WordPress Admin Panel.

Step 13: Navigate to template > download.php. Open the created download.php Download template file.

How to make Download page Template for Wordpress - Open the Download.php Template

Step 14: Paste the below-provided template file PHP code. Just Copy And Paste on the "download.php" Section

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.

global $post;
$download_name = get_post_meta($post->ID, 'download_name', true);
$download_link = get_post_meta($post->ID, 'download_link', true);

        <div class="wp-block-image">
            <figure class="aligncenter size-full">
                <img width="720" height="450" src="<?php echo the_post_thumbnail_url('medium') ?>" alt="Thumbnail">

        <h1 class="has-text-align-center"><?php echo get_the_title(); ?></h1>
        <h2 class="has-text-align-center">Download <?php echo $download_name; ?> file</h2>

        <div class="wp-block-button has-custom-width wp-block-button__width-50 is-style-outline has-text-align-center">
            <a href="<?php echo $download_link; ?>" class="wp-block-button__link has-white-color has-global-color-1-background-color has-text-color has-background" style="border-radius:50px">
how to add download page on wordpress - paste php Code


 Download Page in WordPress to Force Users to Download Files on Download Page

Now your Download Page Setup is Fully Completed. So, next, go to another Function for the Link Creation Section.

Next, you need to make the Download link meta box on the post section. this Meta Box was Helps to give the Download link and Download Page Title on the Download.

This Meta Box is very important to access Download Page. you finish them all set up on the below section now you see the meta box below on your Post Edit Section. this Metebox was Helps to Give the Downlink and Download Page Title. Now see how to set up this Metabox section in your Post edit Section.

Step 15: Again, go to the Appearance > Theme File Editor on your WordPress Admin Panel.

Step 16: Now you are all theme Coding files are Shows Here. Select the function.php file on the theme edit section.

Step 17: add the below PHP Codes on the last line of function.php

  /* Set endpoint of URL */
add_rewrite_endpoint('download', EP_PERMALINK);

function guideflare_download(){
    add_rewrite_endpoint('download', EP_PERMALINK);

add_action('init', 'guideflare_download');

/* Set custom Safelink page template */
function guideflare_download_template(){
    global $wp_query;

    // If the request is fail, it will back to the main post
    if (!isset($wp_query->query_vars['download']) || !is_singular()) return;

    // Include the custom safelink (download) template
    include get_template_directory() . '/template/download.php';

add_action('template_redirect', 'guideflare_download_template');

/* Meta box in posts edit */
function download_details() {
    global $post;
    $download_name = get_post_meta($post->ID, 'download_name', true);
    $download_link = get_post_meta($post->ID, 'download_link', true);
    <b style="text-transform:capitalize">Download Link Title</b>
    <p><input style="width:98%" type="text" name="download_name" value="<?= $download_name ?>" /></p>
    <b style="text-transform:capitalize">Download Link/URL</b>
    <p><input style="width:98%" type="text" name="download_link" value="<?= $download_link ?>" /></p>

function add_post_metaboxes() {
    add_meta_box('download_details', 'Download Link Box', 'download_details', 'post', 'normal', 'high');

add_action('add_meta_boxes', 'add_post_metaboxes', 0);

function wpwm_save_postdata($post_id) {
    // First, we need to check if the current user is authorized to do this action.
    if ('page' == @$_REQUEST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) return;
    } else {
        if (!current_user_can('edit_post', $post_id)) return;

    $wpwm_meta = array('download_name', 'download_link');

    // If saving in a custom table, get post_ID
    $post_ID = @$_POST['post_ID'];
    foreach ($wpwm_meta as $meta_key) {
        if (isset($_POST[$meta_key])) update_post_meta($post_ID, $meta_key, $_POST[$meta_key]);

add_action('save_post', 'wpwm_save_postdata');

Now Successfully created meta box on the all post Edit Section. When you create a new post, download link meta boxes are also created.

Step 18: Now go and create a new post or go and see Exiting Post. you can see the Download link Matabox on all posts.

Step 19: Add link and title text to the below appear download boxes.

Download page script for wordpress
Download page script  fo wordpress

Step 20: Before creating the download button on the post, click Save Draft to save the post as a draft.

Download page Script for wordpress - save the post as draft

Your website link structure is very important to generate the Download link on WordPress. So, the Download page Structure the very important to redirect the Download. your website URL structure is not good and maybe not good for the download Page.

Step 21: Navigate to the right sidebar Permalink section in the post editor and copy the generated URL.

Download page script for Wordpress

Step 22: The create download button and paste the copied URL. After pasting the URL, type the URL with the ending character /download/. Eg.

How to Create Download Page in WordPress without Plugins

/download/ is very important to all posts. So never forgot to provide /download/ after ending URL.

Step 23: Publish the post or hit the Update button to save the post.

Step 24: Navigate Settings > Permalinks to visit the permalinks page.

Step 25: Just click the Save Changes button to flush the permalink of your website.

How to Create Download Page in WordPress without Plugins

Step 26: Go to the download link added published post and check the download link.

Step 27: Now successfully Safelink Page (Download Page) has been created without errors.

Final Words

Overall, we covered all detailed information about creating a Safelink page (Download Page) on WordPress. After implementing the function, the Safelink page is automatically generated for all single posts. 

Just call the Safelink Page (Download Page) by a specific URL like

 This is very useful for downloadable content providing and following my step-by-step process guide to creating a fantastic Safelink Page (Download Page) on your WordPress. 

 If you have any queries related to this article, comment below your queries in the comment box.

Post a Comment

Spam is not welcome here. Any form of unsolicited promotional content, repeated messages, or irrelevant comments will be removed. Please contribute meaningfully to the discussion. Failure to adhere to these guidelines may result in moderation, including the possibility of being blocked. Let's keep the conversation engaging and on-topic!