
Hey, wanna make your WordPress post stand out with a dope download button that’s got a progress bar? I’m gonna show you how to copy-paste one chunk of code into a Custom HTML block, and it’ll work like a charm right in preview. It’s got a slick gradient, a smooth animation, and it’s mobile-friendly too. Plus, I’ll tell you exactly where to swap in your file’s URL, throw in some use cases, pro tips, and a troubleshooting table to save your day. Let’s find out how to custom wordpress download button to your wordpress post.
What’s So Cool About This Button?
This button is next-level:
- Rocking an orange-yellow gradient that flips on hover.
- Progress bar glides from 0% to 100% when clicked.
- Downloads your file automatically after the animation.
- Looks great on phones, tablets, and desktops.
- One code block, no plugins, done in minutes.
You’re gonna love how easy this is!
Read More about How to Earn Passive Income from Blogging in 2025: A Beginner’s Guide here.
Step 1: Copy the Code
Here’s the full code you gave, with line numbers on every single line (no descriptions, just numbers). I’ve added responsive CSS to make it mobile and tablet-friendly. Copy this whole thing:
<div id="download-container">
<button id="downloadBtn" class="download-button">
⬇️ Download File
</button>
<div id="downloadProgressWrapper">
<div id="downloadProgress">0%</div>
</div>
</div>
<style>
/* Container styling */
#download-container {
text-align: center;
padding: 30px;
}
/* Default button style */
.download-button {
padding: 14px 30px;
font-size: 18px;
background: linear-gradient(135deg, #007bff 0%, #00c6ff 100%);
color: white;
border: none;
border-radius: 10px;
cursor: pointer;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
transition: all 0.3s ease;
}
/* Desktop hover effect only */
@media (hover: hover) and (pointer: fine) {
.download-button:hover {
transform: scale(1.06);
background: linear-gradient(135deg, #00c6ff 0%, #007bff 100%);
}
}
/* Mobile & Tablet: force the hover effect always */
@media (hover: none) and (pointer: coarse) {
.download-button {
transform: scale(1.06);
background: linear-gradient(135deg, #00c6ff 0%, #007bff 100%);
}
}
/* Progress bar wrapper */
#downloadProgressWrapper {
margin-top: 25px;
display: none;
width: 100%;
max-width: 400px;
margin: 25px auto;
border: 1px solid #ccc;
border-radius: 5px;
overflow: hidden;
}
/* Progress bar itself */
#downloadProgress {
width: 0%;
height: 20px;
background: linear-gradient(to right, #007bff, #00c6ff);
transition: width 0.1s ease-in-out;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-weight: bold;
}
/* Responsive adjustments */
@media (max-width: 600px) {
.download-button {
padding: 10px 20px;
font-size: 16px;
}
#downloadProgressWrapper {
max-width: 300px;
}
}
@media (max-width: 400px) {
.download-button {
padding: 8px 15px;
font-size: 14px;
}
#downloadProgressWrapper {
max-width: 250px;
}
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function () {
const downloadBtn = document.getElementById("downloadBtn");
const downloadProgress = document.getElementById("downloadProgress");
const downloadWrapper = document.getElementById("downloadProgressWrapper");
downloadBtn.addEventListener("click", function () {
const fileURL = "https://example.com/yourfile.pdf"; // Replace with your actual file URL
downloadWrapper.style.display = "block";
let width = 0;
const interval = setInterval(() => {
width++;
downloadProgress.style.width = width + "%";
downloadProgress.textContent = width + "%";
if (width >= 100) {
clearInterval(interval);
setTimeout(() => {
const link = document.createElement("a");
link.href = fileURL;
link.download = "";
link.rel = "noopener";
document.body.appendChild(link);
link.click();
link.remove();
}, 100); // slight delay
}
}, 50); // 5 sec progress bar
});
});
</script>
This code’s got it all—button, styles, and logic—in one go. The new @media
rules (Lines 26-43) shrink the button and progress bar for phones and tablets.
Step 2: Swap the File URL
You need to update the file URL to point to your actual file (like a PDF or ZIP). Look for Line 51:
const fileURL = " https://example.com/yourfile.pdf "; // 👉 Replace with your actual file URL
Here’s how to get your URL:
- In your WordPress dashboard, go to Media > Library.
- Upload your file (e.g.,
my-ebook.pdf
) or pick an existing one. - Click the file and copy the File URL (e.g.,
https://yoursite.com/wp-content/uploads/2025/05/my-ebook.pdf
). - Replace the dummy URL in Line 51 with your real one, like:
const fileURL = "https://yoursite.com/wp-content/uploads/2025/05/my-ebook.pdf"; // 👉 Your file URL
Test the URL in your browser—it should download the file instantly. Use HTTPS for safety.
Step 3: Start a New Post
- Log into your WordPress dashboard.
- Click Posts > Add New.
- Add a title like “Download My Free Goodie with This Slick Button!”.
Step 4: Paste the Code
- Click the + icon to add a block.
- Type
/customhtml
and hit Enter to add a Custom HTML block. - Paste the entire code from Step 1 (with your updated URL) into the block.
- It’ll show as raw code in the editor, but it’ll turn into a button in preview.
Step 5: Test It in Preview
- Click Preview (top-right) to check your post in a new tab.
- You’ll see a shiny button with “⬇️ Download File” and that gradient vibe.
- Click it:
- The progress bar should slide from 0% to 100% in 5 seconds.
- At 100%, your file should download (if the URL’s good).
- It works in preview, so you can mess around before publishing.
- If it’s not working, check the troubleshooting table below.
- when u paste the code in custom html block it should look like this
Step 6: Spice Up the Post
Add some text to hype it up using Paragraph or Heading blocks. Here’s a vibe:
## Grab My Free File!
Yo, I slapped a dope download button on this post! Click it to snag my free file—it’s got a progress bar that moves as it preps your download. Works on your phone too!
[Custom HTML block goes here]
Wanna use this button yourself? Copy the code and swap the URL. Ping me on X if you’re stuck! 🚀
Toss in keywords like “WordPress download button” or “mobile-friendly button” to get Google’s attention.
Use Case Examples
Here’s how you can use this button to level up your site:
- For Bloggers: Share your eBook or cheat sheet with a stylish download button that screams “pro”. Think “Get my free blogging guide!” with a slick animation.
- For Developers: Distribute code snippets, ZIPs, or app builds. Perfect for sharing your latest GitHub project with a button that pops.
- For Teachers: Let students download study materials or PDFs in style. Imagine a button for “Class 10 Math Notes” that looks way better than a plain link.
- For Marketers: Deliver lead magnets like whitepapers or templates without clunky plugins. A button for “Free SEO Checklist “‘will get more clicks than a boring form.
Also Read : How Much Can You Earn from Blogging in 2025?
Pro Tips & Hacks
Wanna look like a WordPress wizard? Try these:
- Security Boost: The code already has
rel="noopener"
(Line 64) to keep downloads safe from sketchy sites. - Sticky Button: Make the button stick to the bottom of your post for easy access. Add this to the
<style>
section (before Line 44):#download-container { position: sticky; bottom: 20px; z-index: 100; } <!-- Line XX -->
- Color Swap: Change the gradient in Lines 5 and 24 to match your brand (e.g.,
#1e90ff
to#00b7eb
for blue). - Faster Animation: Cut the
50
in Line 69 to30
for a 3-second progress bar. - Accessibility: Add
aria-label="Download file"
to the button (Line 12) for screen readers:aria-label="Download file"
.
Troubleshooting Table
Got issues? This table’s got your back:
Issue | Fix |
---|---|
Button not visible | Check if <style> (Lines 21-44) and <script> (Lines 45-72) are included. |
Download doesn’t start | Ensure the file URL in Line 51 is correct and public. Test it in a browser. |
Progress bar stuck | Script might be incomplete. Re-copy the full code, especially Lines 45-72. |
Styling broken | Add !important to styles (e.g., Line 5) or use browser Dev Tools (F12) to inspect and tweak CSS. |
Publish and Flex
- Add tags like “Web Dev”, “WordPress Hacks”, “Cool Buttons”.
- Set a featured image—a screenshot of the button works great.
- Hit Publish.
Read More about How to Send Large Files Free Like a Pro
Why This Rocks
This code’s all-in-one, so you don’t need plugins or theme edits. The Custom HTML block handles everything, and the button looks fire on phones thanks to the new @media
rules (Lines 26-43). You’ll see it work in preview, no stress.
Show off your simple download button!
Paste the code, update the URL, and hit preview—the button’s ready to roll. Share your post with #WebDev or #TeluguTech. Got stuck? Yell, and I’ll fix it!