Add A Featured Post Link

This forum won’t let me add more replies to the Share what you are working on and using! thread, so you guys get a new post.

I’ve been thinking of ways to add a “Featured Post” feature on my sites. This is the easiest idea to implement. Using the Javascript for providing a link to a Random post, you can use the same approach to adding a Featured Post link to your site. You control what post to feature by simply changing the link in your custom Javascript. It will look something like this:

image

First create a placeholder post and pin it on your homepage. I created a post titled “:notes: Featured Song :notes:”. Then here is the custom Javascript that I use on my site:

/* Featured Song Link */
var a = document.querySelector('a[href="https://write.as/now-listening-to/featured-song"]');
if (a) {
  a.setAttribute('href', 'https://nowlisteningto.dinobansigan.com/hate-me-sometimes');
  a.setAttribute('title', 'Featured song for this month');
}
var b = document.querySelector('a[href="/now-listening-to/featured-song"]');
if (b) {
  b.setAttribute('href', 'https://nowlisteningto.dinobansigan.com/hate-me-sometimes');
  b.setAttribute('title', 'Featured song for this month');
}
var c = document.querySelector('a[href="https://nowlisteningto.dinobansigan.com/featured-song"]');
if (c) {
  c.setAttribute('href', 'https://nowlisteningto.dinobansigan.com/hate-me-sometimes');
  c.setAttribute('title', 'Featured song for this month');
}

Just remember to change the link to something else every month or every week, or however often you want to.

A post was merged into an existing topic: Share what you are working on and using!