Add/Update a Link to Latest Blog Post’s URL

by Dustin Tantum | WordPress | 0 comments

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 link/button's URL to your most recent published blog post — no manual edits required!

It's perfect for landing pages, call-to-actions, and onboarding flows where your latest post is always the most relevant next step.

Requirements

  • WordPress 6.5+
  • PHP 8.0+

What It Does

When the page loads:

  1. JavaScript fetches the URL of the most recent post via WordPress admin-ajax.php
  2. It finds the first element with the class .nurbid-latest-post-url
  3. It replaces the element's href with the permalink of the latest published post

How It Works

  1. A server-side PHP function retrieves the latest published post
  2. A WordPress AJAX endpoint exposes that URL to the front end
  3. Footer JavaScript updates the href of matching <a> elements

Install

From GitHub Releases

  1. Download nurbid-latest-post-url-x.y.z.zip from the GitHub Releases page (use the latest release asset)
  2. Go to Plugins > Add New > Upload Plugin
  3. Upload the zip, then click Install Now and Activate

Setup

1. Add a link or button

In your page builder, template, or HTML:

<a class="nurbid-latest-post-url" href="#">Read Latest Post</a>
  • Use any valid anchor (<a>)
  • May be inside or outside a <button> wrapper
  • Add the class nurbid-latest-post-url
  • Use a placeholder href="#" — it will be replaced automatically

2. Done

The URL updates on each page load. No settings screen.

Shortcode (optional)

Embed the latest post URL in content:

[nurbid_latest_post_url]

Works in:

  • Posts and pages
  • Page builders that support shortcodes
  • PHP templates: echo do_shortcode('[nurbid_latest_post_url]');

What Else?

Need multiple buttons? Want to extend this for CPTs or categories? Let us know in the comments.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


IT Guides

Practical tips and step-by-step strategies for the IT choices small businesses face every day. When the path isn’t obvious, Nurbid guides.

Table of Contents