Wordpress Blogroll bug fix
May 10th, 2007 | Posted in Development, Wordpress
I recently added a new feature to the home page. The “Sites and Articles of Interest” section is built using the Blogroll manager. As well as displaying the title and description, I wanted to display the date links were posted. Referring to Wordpress documentation I learnt that passing show_updated=true to wp_list_bookmarks() as an argument would return the date formatted, but it didn’t.
Digging into admin-db.php I discovered that when links are saved, the link updated date value had been left out. Therefore all links were defaulting to the database fields default value of 00-00-0000 00:00:00. The php template which holds wp_list_bookmarks() function checks the first two characters of the date, if they equal “00″ then it does not display the date.
To display the date I had to add the date field and value to the Blogroll’s save link SQL query, which is found in admin-db.php.
Backup admin-db.php, then at around line 350…ish, replace:
-
if ( $update ) {
-
$wpdb->query("UPDATE $wpdb->links SET link_url=’$link_url’,
-
link_name=’$link_name’, link_image=’$link_image’,
-
link_target=’$link_target’, link_category=’$link_category’,
-
link_visible=’$link_visible’, link_description=’$link_description’,
-
link_rating=’$link_rating’, link_rel=’$link_rel’,
-
link_notes=’$link_notes’, link_rss = ‘$link_rss’
-
WHERE link_id=’$link_id’");
-
} else {
-
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES(’$link_url’,'$link_name’, ‘$link_image’, ‘$link_target’, ‘$link_category’, ‘$link_description’, ‘$link_visible’, ‘$link_owner’, ‘$link_rating’, ‘$link_rel’, ‘$link_notes’, ‘$link_rss’)");
-
$link_id = $wpdb->insert_id;
-
}
with
-
if ( $update ) {
-
$wpdb->query("UPDATE $wpdb->links SET link_url=’$link_url’,
-
link_name=’$link_name’, link_image=’$link_image’,
-
link_target=’$link_target’,
-
link_visible=’$link_visible’, link_description=’$link_description’,
-
link_rating=’$link_rating’, link_rel=’$link_rel’,
-
link_notes=’$link_notes’, link_rss = ‘$link_rss’,
-
link_updated = ‘$time’
-
WHERE link_id=’$link_id’");
-
} else {
-
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss, link_updated) VALUES(’$link_url’,'$link_name’, ‘$link_image’, ‘$link_target’, ‘$link_description’, ‘$link_visible’, ‘$link_owner’, ‘$link_rating’, ‘$link_rel’, ‘$link_notes’, ‘$link_rss’,'$time’)");
-
$link_id = $wpdb->insert_id;
-
}
Hope this helps others. Any problems then let me know.
Leave a comment
Latest Posts
08 Jul
Site Launch - ASHT.INFO
Posted in Codeigniter, Development, Freelancing, My Work News, PHP
01 Jul
30 Jun
Four blokes goin ape…
Posted in Funny
24 Jun
Please Please Please
Posted in Funny
18 Jun
On meh bike
Posted in Jus' Ramblin', Rants
![[UPDATED] At last , something nice to say about NTL (Virgin Media)](/images/commented_bullet.png)










