Do you find that keeping your “Read Latest”, “Start Here”, or “Get Started” buttons current to be a hassle?
If so, this simple plugin eliminates those hassles by automatically setting a button’s link to your most recent blog post — no manual edits required!
It’s perfect for use in landing pages, call-to-actions, or onboarding flows where your latest post is always the most relevant next step.
What It Does
This plugin does three things when the page loads:
- JavaScript fetches the URL of the most recent post using WordPress’s
admin-ajax.php
- It finds the first element with
.update-latest-post-url
- It replaces the
href
with the permalink of the latest published post
Examples
Using class name: Nurbid’s Latest Blog Post
Using shortcode: https://nurbid.com/dark-theme-for-upmind/
How It Works
This plugin does three things:
- Defines a server-side PHP function to retrieve the latest published blog post
- Registers a WordPress AJAX endpoint to expose that URL to JavaScript
- Injects JavaScript into the page footer that updates the
href
of any<a>
element with a specific CSS class
Step-by-Step Setup
1. Download and Install the Plugin
- Go to your site’s Plugins > Add New > Upload Plugin
- Upload
update-latest-post-url.zip
- Click Install Now, then Activate
2. Add a Button or Link Element to Your Site
In your page builder, template, or HTML:
<a class="update-latest-post-url" href="#">Read Latest Post</a>
- Use any valid anchor tag (
<a>
) - Can be inside or outside a
<button>
wrapper - Assign the class:
update-latest-post-url
- Set a placeholder
href="#"
— this will be replaced automatically
3. That’s It — The URL Will Update Automatically
Optional: Use the Shortcode
You can also embed the latest post URL directly into page content:
https://nurbid.com/dark-theme-for-upmind/
This works inside:
- Posts
- Pages
- Page builders that support shortcodes
- PHP templates (via
echo do_shortcode('https://nurbid.com/dark-theme-for-upmind/')
)
What Else?
Need multiple buttons? Want to extend this for CPTs or categories? Let us know in the comments.
0 Comments