Sivel.net  Throwing Hot Coals


Adding Additional Links to the Output from wp_list_pages

One common question in the WordPress IRC Channel is how to add external links, or links to content other than pages, to the output of wp_list_pages, usually not that exactly but that is what they mean. You can of course modify your theme by inserting <li><a href="http://example.org">Example.org</a></li> <p> immediately following the wp_list_pages function however, this is not always the best solution. In my case I am working on developing a theme for distribution and testing it in the best way possible by running it as my main theme on my site. Since I want extra links to appear there and I don’t want to have content in the theme that will not be distributed to users, filtering the output of wp_list_pages works wonderfully.

You can put this following code in your themes functions.php, or in a plugin. Since I am trying to keep from modifying my theme, a plugin is the better option.

add_filter('wp_list_pages', 'add_forum_link');
function add_forum_link($output) {
        $output .= '<li><a href="http://forum.example.org/">Forum</a></li>';
        return $output;
}

The above code will add a link to a forum at http://forum.example.org/.

Enjoy!

Code PHP Snippet WordPress

February 27 Plugin Updates

I am releasing updates to 4 of my plugins today. The plugins that have been updated are AJAXify FAQ-Tastic, Moderate Selected Posts, Possibly Related Recent Posts and Lightview JS. The most important updates to these plugins are PHP Notice fixes and enqueue-ing scripts and styles that were previously just printed to the head. You can see each plugins respective change log at the links provided. Enjoy!

Asides Plugins WordPress

WordPress One Liner to Remove Style Tags from Posts using [gallery] Shortcode

One of the biggest things that irritates me when using the [gallery] shortcode is that style tags are inserted into the post content. Why does this irritate me? Because this does not validate as XHTML 1.0. Luckily the fix is quite easy. Add the following code as a plugin or to your themes functions.php and say goodbye to the style tags in your post content.

add_filter('gallery_style', create_function('$a', 'return preg_replace("%%s", "", $a);'));

One side effect to doing this is that the CSS normally outputted to into your post content is no longer output at all. You will need to add the CSS to your themes css file, usually style.css. The following css is the default output:

The width for .gallery-item is a dynamic value determined by the columns attribute specified in the [gallery] shortcode. The default is 3 columns which makes the width 33%, floor(100/$columns).

I have also written a plugin called Gallery Shortcode Style to Head which does a forward lookup to determine if a post uses the [gallery] shortcode and if it does, prints the default CSS to the head. While the plugin works and performs its function, I still prefer a solution that has less overhead associated with it, hence the code provided in this post.

Code One Liner PHP Snippet WordPress

Shadowbox JS WordPress Plugin v2.0.3.3 Released

The Shadowbox JS WordPress Plugin has been updated to version 2.0.3.3. New to this update is additional skins and automatic language detection. See the Change Log for all changes. Enjoy!

Asides News Plugins WordPress

WordPress One Liner to Customize Author Permalink

Several people have asked me recently how to customize the author permalink from being /author/admin to something like /profile/admin. I have created a simple one line piece of code that you can drop in your themes functions.php to achieve this.

add_filter('init', create_function('$a', 'global $wp_rewrite; $wp_rewrite->author_base = "profile";'));

Drop this into your themes functions.php wrapped in <?php ?> tags, then visit the WordPress admin, go to Settings->Permalinks then off you go. By visiting the permalinks settings page it should flush the rewrite rules, but if for some reason it doesn’t go ahead and click “Save Changes”. If you want /author/ to become something other than /profile/ replace ‘profile’ in that one liner with the string of your choice.

Code One Liner PHP Snippet WordPress

Shadowbox JS WordPress Plugin v2.0.3 Released

The Shadowbox JS WordPress Plugin has been updated to version 2.0.3. Don’t be fooled by the version number. This is a big update. New to this update, by popular request, is an admin interface among other updates. See the Change Log for all changes. Enjoy!

Asides CoolStuff News Plugins WordPress

Moderate Select Posts Updated to 1.2

The Moderate Selected Posts WordPress plugin has been updated to version 1.2. New to this version are 2.7 enhancements, admin styling enhancements and localization support. Enjoy!

Asides News Plugins WordPress

WordPress 2.7 Released

WordPress 2.7 has been released! No blog post yet from Automattic on the WordPress blog yet, but should be soon.

Asides CoolStuff News Technology WordPress

WordPress 2.7 Just Released on WordPress.com

WordPress 2.7 was just released on WordPress.com! Congratulations Automattic!

Asides CoolStuff News WordPress

Themes Added to Gmail

I just logged into Gmail for the eight thousandth time today and just got a notice that Google had added themes to the Gmail settings. The Gmail Blog has some more information about this as well as screenshots of the various themes.

Asides CoolStuff News Technology