Posts in the category "WordPress".

WordPress code

Someone at the WP Forums asked how one would list 5 most recent posts but not the current post if it was one of the most recent ones… So, this is what my brain spouted out:

<?php
if( get_query_var(‘p’) ) {
$current = get_query_var(‘p’);
} else {
$postname = get_query_var(‘name’);
$current = $wpdb->get_var(“SELECT ID from $wpdb->posts WHERE post_name = ‘$postname'”);
}
print “<ul>”;
$count = 0;
$posts = get_posts(‘numberposts=6’);
foreach ($posts as $post) :
setup_postdata($post);
global $id;
if ( $count < 5 and $id != $current ) { ?>
<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
<?php
$count++;
}
endforeach;
print “</ul>”;
} ?>

Mighty Nitpicker strikes again

From a WP forum thread:

target=”_new” is deprecated

target=”_new” is annoying

AAAAAAAGH! Target=”_new” doesn’t exist. It’s _blank. If you want a name a window “new” (or have a frame by that name), you should leave the underscore (_) out.

I’m so kind I didn’t write this in the forum… :wink:

Anniversary

One year ago, almost exactly (if I had remembered this on Monday), I started using WordPress. I’m very glad I ventured from the old and familiar environment of Perl in the form of Greymatter to the scary world of databases and PHP in the form of WP. WP has been very easy to use, customise and tweak. After the theme system came in 1.3 it’s been a breeze to upgrade (some people complain about the frequent upgrades. I don’t) especially now that I remember to “document” my core tweaking.

I’m too tired to write anything grandiose. I love WP. I’ve never had any problems with it (well, little error messages or layout-gone-crazy just don’t make me shake in my boots unlike some, it seems).

Happy anniversary!

Awww

These sort of comments just make my little forum volunteer heart flutter.

With the help of my new hero “Minna” over at the WordPress forums I have a new navigation look. I grabbed the necessary css from Michael Heilemann at Binary Bonsai. Minna helped me step by step with changes at the forum.

Thanks Minna!

Trackbacks are back

Whether or not anyone would ever trackback me, trackbacks are back. However, only genuine trackbacks are let through the moderation, I won’t allow site advertisements that really have nothing to do with my post specifically.

WP 1.5.1

22 minutes into the new WP version and I’ve got it installed. Yay.

Only one thing:
Plugin list
That’s the plugin list and green shows which are activated. I mean, GAG! Look at that green! And blue links! I don’t like blue, but if it’s gotta be blue (I KNOW there are a few admin “themes”) then it can’t have green — at least not that kind of green.

*goes to tweak the admin stylesheet*

Ah, a bit better. I thought about leaving all the rows as plain grey (or white) but figured maybe distinguishing activated plugins comes in handy when I’m in a real hurry or suddenly can’t read……….
Plugin list after tweak

Now, where was the other green ghastly thing I caught a glimpse of…

Note to self: The next time you upgrade, remember to save a copy of admin quicktag hacking… AND remember to check which plugin files are in wp-admin

Exclude pingbacks from comments RSS

A weird character in Jafer’s pingback title (or site title, actually) messed with my comment feed, so I decided to exclude pingbacks (as I won’t allow trackbacks) from my comments feed. I tweaked wp-commentsrss2.php file (found in the root WP folder), around lines 36 and 44:

AND $wpdb->comments.comment_approved = ‘1’ AND $wpdb->comments.comment_type != ‘pingback’

Comments are of type ” (null) and trackbacks are ‘trackback’, so I think putting comment_type = ” would work as well and you wouldn’t have to put a != (not equals) for both pingbacks and trackbacks.

[edit: May 9] That was a short-lived hack. WP1.5.1. solves the problem with odd characters causing grief for RSS feed readers [/edit]

Tweaking Since Last Visit hack

I don’t use the JavaScript version of Alex King’s Since Last Visit hack/plugin because I don’t like to depend on JS. And I didn’t even get it working back when I tried it out :laugh:

After keeping the comment referred to in my previous post I noticed that the targetted post was showing new comments. So, I added a requirement to the database query in function ak_new_comments: and comment_approved not like 'spam' making it say

if (isset($ak_last_visit)) {
 $last_visit = date(“Y-m-d H:i:s”, $ak_last_visit);
 $comment_date = $wpdb->get_var(“SELECT MAX(comment_date)”
 .”FROM $tablecomments ”
 .”WHERE comment_post_ID = ‘$post_id’ and comment_approved not like ‘spam’
 );
 if ($comment_date > $last_visit) {
  echo $html;
 }
}

around line 178. No more ghost comments.

(Database studies came in handy, yet again.)

Cheerful gratitude

I love helping at the WP Forums, but replies like this make the smile stay on my face a while longer: It’s so quiet at work. Everyone’s probably having a vacation and I’m here sitting, venturing into the world of telecommunication cables…

Forum-illiteracy

It’s amazing how some people don’t seem to read what’s been written before they reply to a thread. Just check out this thread at the WP Forums, and see how this Deborah is trying to help… Also, Lorelle was being very helpful, too (she does reply to a lot of threads so I’m sure that was a temporary lapse).

:roll: