Recent Pings

I wanted to re-do my 'recent pings' code for trackbacks from other sites. This appears on my homepage.

The criteria were:

  1. Only display pings from elsewhere (not internal pings)
  2. Display N pings.

These required me to keep count of how many pings had been displayed, and not display internal pings. (I couldn't just say 'only show N pings', and then not show a subset as the length of the list would change.)

Here's the code:

<MTSetVar2 name="count" value="0">

<div class="module">

<h2 class="module-header">Received Pings</h2>
  <div class="module-content">
  <ul class="module-list">

    <MTPings sort_order="descend">
      <MTIfLess a="[MTGetVar2 name='count']" b="10" numeric="1">
        <MTIfNotEqual a="[MTBlogName]" b="[MTPingBlogName]">

        <li class="module-list-item"><MTPingedEntry> <a 

        pinged by 

        </MTPingedEntry><a href="<$MTPingURL 
        title="<$MTPingDate$> - <$MTPingExcerpt remove_html="1" 
        encode_ampersands="1"$> - from <$MTPingBlogName 
        remove_html="1" encode_ampersands="1"$></a></li>

        <MTAddVar name="count" value="1">


This code requires the use of several plugins to movabletype.

These are listed below:

  1. Arithmetic which in turn requires Expressions
  2. MTCompare
  3. MTPingedEntry (original site)
  4. Amputator

Essentially, this piece of code will first set a count to zero, then it will work through the list of trackback pings. Whenever the count is less than 10, it will start to process the ping (i.e. it only does 10 pings). The details of the ping are output, and the count is incremented.

The Amputator plugin provides the encode_ampersands filter. This helps to ensure valid HTML is produced (the & symbol in URLs should be written as &amp; when that URL is in a webpage)