Skip to main content

Latest Posts v1.0 by Cypher

While looking for plugins for Jutia Group I stumbled upon Latest Posts v1.0. It is on the left side, under "10 Newest Entries".

I needed some more functionality out of it so I took the liberty to modify the code a bit. Just to make it a tad more flexible.

I started by changing the function call for inside the template. I changed it from:


What this does is, before the function is called its existence will be verified. This will prevent your theme from braking and your pages loading halfway and then displaying errors when the function is called:

  • if you disable the plugin (now you can turn on and off the plugin without the visitors getting page errors)

  • the plugin file is moved, corrupted or deleted

In other words, if something happens to the plugin and you are unaware of the problem, your site will not brake. This of course is bad, but it will not have a negative effect on your site.

My next change was to make the number of posts being displayed flexible. With other plugins and the ability to call the function in any page or post you might want to display different number of posts at different places.

I started by deleting the variable

from the global declaration.

Then I placed that variable in the function declaration.


function cypher_latestposts($before='', $after='

function cypher_latestposts($max_posts, $before='', $after='

Now when you call your function you can set the number of post to be displayed at the function call location. Like this:

In this example I want 10 posts. You can change this number to anything you want.

Here is an extra. Some of you might want to display your links in a list, others separated by a comma (no idea why), slashes, hyphens or as in the original just with a line breaker. So what you will do is change the function declaration like this:

function cypher_latestposts($max_posts, $before='', $after='

function cypher_latestposts($max_posts, $before, $after)

When you call your function just insert what you want to separate the links with. Here are some examples:

<?php if (function_exists('cypher_latestposts')) cypher_latestposts('10','
  • ','
  • '); ?>
    <?php if (function_exists('cypher_latestposts')) cypher_latestposts('10','+','
    '); ?>


    Popular posts from this blog

    Format MAC Address [JavaScript]

    I am currently working on a project which will allow users to register their Wi-Fi enabled, non-web browser enabled, devices on the network. These are devices like printers, Apple TV, and Xbox*. One of the data points that have to be collected from the user is the device MAC address. The project customer wants that address to be properly formatted when they see it in the support ticket.

    We have several options. We can format the address either on the back-end after the form has been submitted. Or we can format it on the front end via a separate text field for each character pair, but that is too many fields to handle. A better solution is to use a single field and format the user input at the time of input or upon submit. In those cases, the former is better because the data will already be formatted when the overall form input is being validation after the user clicks the “Submit” button.

    We are going to format the user input as it is being provided, thus having proper data when vali…

    How to setup Coda 2 to push to GitHub?

    Setting up a new site in Coda 2 and cloning a GitHub remote repository is not that big of a deal. Where you will most likely run into problems is when you try to push your changes to the GitHub remote repository. Below I will show you how to update the Git config file in your local repository so you do not run into one of the following errors:
    git push failed remote: Remote anonymous access to repository deniedgit push origin master Username: fatal: Could not read passwordThe GitHub repository address I am going to use is that of Source Code DNA: I will assume that you have already setup your Coda 2 site profile and cloned your repository, you have made some changes, and now you are ready to push those changes to your projects GitHub repo.

    SNOOZ: Sound. Sleep.

    I was on the Snooz Kickstarter page today, revisiting the project’s details and timeline progress. The device, which is a white-noise generating machine, recently became available for pre-order. Snooz is meant to be an alternative to having a TV or a stationary fan running at bed time. In my case, I bought it for my wife so we can get the TV out of the bedroom.

    Whilst on the comments page I read the following comment, posted recently by Ken Tran:

    I'm not a fan of the new fabric design. ...
    I must disagree. If you take a look at the original design, which is all plastic and no style, I must say it is fugly. It is all utilitarian - not something I rally want to look at or see when I walk into the room. The final design, seen on the right, is something that beacons to be explored, looked at, utilized.

    I am a big fan of Bang & Olufsen. They use fabric from Kvadrat in their line of products. Incorporating soft materials like fabric or leather in something which is meant to be place…