Page Lists Plus v0.1.7

There have been various updates to Page Lists Plus since I last blogged about it here, so it’s time for a quick catch-up. Here are some of the more recently added features:

Remove Title Attributes

By default, WordPress adds a title attribute to every link in a page list, duplicating the title of the page linked to as both the link text and the title attribute value.

This is a misuse of the title attribute. Title attributes should be used to provide additional information where it’s needed, not to duplicate all information.

You can now use Page Lists Plus to remove title attributes from your page lists, reducing code bloat and improving accessibility.

Custom Title Attributes

Sometimes, though, a title attribute that provides further information about a link can help. In that case, you don’t want to remove the title attribute, but to change its value. Page Lists Plus now lets you do that too, giving you the chance to improve your website’s usability and accessibility.

Nofollow Links

Page Lists Plus is often used to add external links to Page lists. By creating a dummy page, and then using PLP’s option to redirect links to it elsewhere, you can insert any link you want anywhere you want in your Page lists.

If you have a policy of adding rel=”nofollow” to external links to tell search engine bots not to follow them, then you’ll want to be able to nofollow external links in Page lists too. You may also want to nofollow certain links to concentrate PageRank on particular parts of your site for SEO reasons. Page Lists Plus now lets you do this.

Open Links in New Windows

You may also want to add target=”_blank” to links to external sites in Page Lists, so that they open in a new browser window. Page Lists Plus now lets you do this too (but do be aware that target=”_blank” won’t validate if you’re using a strict rather than a transitional doctype).

Most of these features have been added in response to requests by users. If there’s something that you’d like Page Lists Plus to do that it doesn’t already, then please make a feature request of your own.

WordPress provides a template tag that outputs all of the categories to which a post belongs: the_category(). You might use this to create a complete, comma separated list of a post’s categories using something like this: <p class="postCategories">Categories: <?php the_category(', '); ?></p>.

Sometimes, though, you don’t want a complete category list, because some of your categories are for administrative use only. Unfortunately, there’s no easy way to generate an incomplete category list. You can’t just pass a variable to this function excluding a category; the_category('exclude=1') doesn’t work.

So if we want an incomplete category list then we need to create our own custom function. Adding the following code (adapted from code suggested by MichaelH on the WordPress forums) to your functions.php theme file will create a function that generates a comma separated list of a post’s categories excluding “FirstCat” and “SecondCat”:

function incomplete_cat_list($separator) {
  $first_time = 1;
  foreach((get_the_category()) as $category) {
    if ($category->cat_name != ‘FirstCat’ && $category->cat_name != ‘SecondCat’) {
      if ($first_time == 1) {
        echo ‘<a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $category->name ) . ‘” ‘ . ‘>’  . $category->name.’</a>’;
        $first_time = 0;
      } else {
        echo $separator . ‘<a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.’</a>’;
      }
    }
  }
}

To use this function, just add something like this to your index.php or single.php theme files: <p class="postCategories">Categories: <?php incomplete_cat_list(', '); ?></p>.

Replace “FirstCat” (“SecondCat”, etc.) with the names of the categories that you want to exclude. If you want something other than a comma between categories, then change the value of $separator passed when you call the function.

Page Lists Plus v0.1.2

There’s a new version of Page Lists Plus now available for download from the WordPress Plugin Repository. Here are some of the new features:

  • Add a “Home” link at the start of your Page lists
  • Add class=”first_item” to the first item in your Page lists (useful if you want to use a Page list as a horizontal navigation menu with separators between items)
  • Add span tags inside all list items (again, useful for styling)
  • Choose which options are visible on the Write > Page and Manage > Page screens to avoid clutter

If you’re already using Page Lists Plus and any of that looks useful to you, then you may want to upgrade. If you aren’t yet using Page Lists Plus, then there a now a few more reasons why you might want to.

A month ago today, I made my first plugin available to the general public: Alt Link Text. This was a simple plugin that made it easy to link to Pages in navigation menus using link text different to the page title.

User feedback has been very good, but it turns out that there are lots of similar things that people would love the plugin to do as well. Suggestions for extra features include making link title attributes editable, providing a way of excluding links from page menus, and making it easy to add rel=”nofollow” to links, etc.

These are all great ideas, so I’ve added them to the plugin.

Now that the plugin does much more than let you specify alternative text for your links, the name “Alt Link Text” doesn’t quite seem to cover it. What the plugin now does is add a range of options to the dashboard that make Page lists configurable. So future releases of the plugin will be called “Page Lists Plus”.

You can download Page Lists Plus for testing now.

If you have any bug reports or feature requests, then please to let me know either through the comments below or by email.

Another quick update on the Alt Link Text plugin: It now adds a checkbox to the Write Page and Manage Page screens that lets you easily exclude pages from your page lists. Without the plugin, removing a page from your navigation menu involves editing the PHP in your theme files, but with the plugin you can now do this through the dashboard.

Please note that if you’re upgrading from an earlier version of the plugin, you’ll need to deactivate and then reactivate (otherwise your database table will be missing the column used for the new feature, and you’ll get a couple of error messages before each of your page lists).

When I named the plugin, it was just going to provide a simple way of changing the link text in navigation menus. It now does rather more than that, so I think a name change is in order. What the new name will be, I haven’t quite decided. Suggestions are more than welcome!