How to surface old posts on your WordPress site

If you have an old post on your WordPress site that you think deserves greater recognition then an age-old way is to modify the published date, pushing to the top of your blog. But this isn’t a great way to do it – links can be broken (WordPress is great at directing URL changes to the new location but it’s not infallible), sitemaps may not update correctly and, well, Google is unlikely to appreciate it, as far as SEO concerns.

Instead, some smart coding changes will allow you to easily mark posts as note-worthy and have them listed at the top, all without changing any URLs.

There are lots of ways to do it but the way I’ve implemented it on this site was the easiest solution for what I wanted to achieve and my configuration.

tl;dr – sticky posts will automatically display first on my theme, so marking any post as sticky but also using the tag of ‘Featured’ will modify it from a sticky post to a ‘featured post’.

So, here’s what I did.

First of all, I made 2 changes to content.php – this is a template part from index.php but your theme may vary.

  1.  When processing the loop, and a tag of ‘Featured’ is found and it’s the home page, I prefixed ‘Featured:’ to the title. The second check is to prevent the prefix from being added onto the main post page.
    <?php if ( has_tag( 'featured' ) && is_home() ) { echo 'Featured: '; } ?>
  2. My theme uses icons to represents different post types, including sticky posts. In this case the icon for sticky posts was just as suitable for featured posts, do I decided not to change this. However, I did change the ‘alt’ text on the image so it is either ‘Featured posts’ or ‘Sticky post’, depending on usage.

For most people this simple change would be sufficient. On my theme, though, I’m running a script that I documented a little while ago, to alert to aged posts. If I’m surfacing a post, chances are I’ll have made sure the content is up-to-date so even if it’s old I don’t want this warning to display. So, I modified this script to not display if the post was sticky.

This can be improved, for instance, by adding specific colouring to the CSS for the featured posts to make them stand out but, for my need, my current changes seem sufficient. Feel free to play with ideas and post your suggestions in the comments.

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from David Artiss

Subscribe now to keep reading and get access to the full archive.

Continue reading