Plugin Directory

Classy wp_list_pages

Author: Alex Dunae

New in version 1.3, you can specify a class to add to the first and list items in a list.

This plugin adds classes or IDs (your choice) to the LI tags generated by WordPress' wp_list_pages() (see more in the WordPress Codex) function.

I found it very frustrating to style the output of wp_list_pages() without having access to these attributes. This plugin allows you to style the output of wp_list_pages() with CSS.

The class name or ID is derived from the URL of the page.

For example,

  • /about/ could have the class about.
  • /about/faq/ could have the class about_faq.

If a page does not have a URL (e.g. your front page) the plugin will set the class or id (depending on what you selected) to frontpage, adding whatever prefix you requested.

For example,

  • / could have the class pg_frontpage.

Existing classes (e.g. page_item or current) are left untouched.

Sample output

<li id="nav-a-new-page" class="first page_item page-item-4"><a href="http://example.com/a-new-page/" title="A new page">A new page</a></li>
<li id="nav-about" class="page_item page-item-2"><a href="http://example.com/about/" title="About">About</a></li>
<li id="nav-another-new-page" class="last page_item page-item-6"><a href="http://example.com/another-new-page/" title="Another new page">Another new page</a></li>

Configuration

Using the Classy wp_list_pages tab in the options panel you can choose whether you want to use IDs or classes, set the token separator and add an optional token prefix.

You can also specify a class to add to the first and last items in a list.

Pretty straight forward...

Did you find this plugin useful?

You can write a "recommendation" for me on my LinkedIn profile.

Download

FYI

Compatibility beta

Your Setup

Log in to vote.

The Consensus

No data
100,1,1

Average Rating

5 stars
4 stars
3 stars
2 stars
1 star
(8 ratings)