One of the best Recent Posts plugins for Wordpress out there is the Coffe2Code Customizable Post Listings. In fact, it does much more. “Display Recent Posts, Recently Commented Posts, Recently Modified Posts, Random Posts, and other post listings…”. Neat.
But, since Wordpress 2.1, there’s a slight problem with it. You see, WP 2.1 changed the way Pages work, so this nifty plugin now fails to tell the difference between posts and Pages. It may not be too much of a problem in some cases, but in this particular site I’m currently working on it gets in the way. Fortunately, there’s an easy fix.
All that needs to be added is this little snippet of code that tells the plugin to only process the posts and not the Pages: post_type=’post’. One doesn’t need to know PHP to do this (I don’t…). Copy and paste will do.
Look for this:
$sql .= “WHERE $tableposts.post_date <= '$now' AND ( $tableposts.post_status = 'publish' ";
if ($include_sticky_posts) $sql .= "OR $tableposts.post_status = 'sticky' ";
$sql .= ")";
and add the bit of code mentioned before, like this:
$sql .= “WHERE $tableposts.post_date <= '$now' AND ( $tableposts.post_status = 'publish' ";
if ($include_sticky_posts) $sql .= "OR $tableposts.post_status = 'sticky' ";
$sql .= ") AND $tableposts.post_type=’post’ “;
Now it works like a charm :).
Unfortunately this pluging hasn’t been updated in a few years, and even the last comment about it on the website is from 2005. At least this will leave them a pingback.
Technorati Tags: Wordpress, Coffee2Code, Customizable Post Listings, Wordpress plugin, Wordpress recent posts
wp_list_bookmarks is a new tag in Wordpress 2.1 that replaces the tags get_links_list and get_links tags, and is the one that’s giving me the more trouble. The documentation page is still a “rough draft”, and the tag itself is bugged (there are a few bug reports filed already).
One thing that I couldn’t do to save my life is display the links list without a title. You used to have to use the parameter ‘title_li=’, wich is supposed to still work. Anyone who has tried will tell you that it doesn’t work so well.Took me a while, but after some searching I found a workaround for it. If you pass the ‘title_li=’ parameter alone, it won’t work. You also have to add ‘categorize=0′
Now, by doing this you’re passing a false value to this parameter, whose description is”Bookmarks should be shown within their assigned Categories”. I think that using a value of 1 should work too if that’s what’s needed, but I haven’t tried that yet.
Technorati Tags: wordpress 2.1, wordpress 2.1 bugs, wp_list_bookmarks
Am I the only one having problems with WP 2.1? I would have two themes finished by now if it wasn’t for the new freaking version of Wordpress not doing what it should do. Tags aren’t working like they should according to the (incomplete) documentation, breaking themes and driving me insane. And still I keep reading how well this new version is working for everyone else. Sheesh.
Technorati Tags: wordpress 2.1, wordpress 2.1 problems
A client asked me for a navigation bar using a custom font for his WordPress theme. I couldn’t just hand code it and use images since he wanted the final user to be able to add pages from the WP control panel. I figured there had to be a way to do that; there is a plugin to replace the post titles with images (gee, can you tell?), so why couldn’t you use it for any other text? It took me a while, but i finally figured it out. This is what i did:
I made a menu on the header with the wp_list_pages tag.
<div id="menu">
<ul>
<?php wp_list_pages('title_li='); ?>
</ul>
</div>
title_li= makes the tag not display a title.
The menu is done, next is converting it to images. I started by getting this Image Replacement WordPress plugin. I had to fix it to get it to work properly. On that page look for a comment by Serge Lafont. I tried that and it worked like a charm.
The plugin lets you specify wich html tag you want to replace (h1, h2, h3, h4, h5, h6, div, span and p), and even set a class. The problem is that the wp_list_cats tag outputs something like this:
<li class="page_item"><a href="...url..." title="Links">Links</a></li>
No good. I needed a tag around the page title. I had to change the output of the wp_list_pages tag, wich is found in the the template-function-posts.php file (on the wp-includes folder).
I had to look around a bit, as php is not really my thing, but i found the part that had to be changed. To locate it, do a search for “function _page_level_out” and scroll down a few lines. The part is this:
$output .= $indent . '
<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '">' . $title . '</a>';
I added a span there, like this:
$output .= $indent . '
<li class="' . $css_class . '"><a href="' . get_page_link($page_id) . '" title="' . wp_specialchars($title) . '"><span class="' . $css_class . '">' . $title . '</span></a>';
I copied the class from the li element, so they’ll both have the same class. Any other one class could be used too though.
Now the wp_list_pages tag outputs this:
<li class="page_item"><a href="...url..." title="Links"><span class="page_item">Links</span></a></li>
Perfect. And there is no problem if you want to use another theme in the future. All you have is an extra span tag that won’t bug.
All left to do is go to the plugin settings and choose a span class “page_item”, and voila, an image menu, fully editable. So far it works fine, at least in IE6, Opera 9 and Firefox 1.5 (all for WinXP).
The only drawback is that you can’t have mouseover effects. Oh well.
Technorati Tags: Wordpress, Wordpress hack