Disclaimer: The following words, and any words put under the category of “nerd shit” are extremely nerdtastic. There is a 62.48% chance that it will make you catatonic. You’ve been warned.
After installing Wordpress for this here crappy mediocre-at-best site, I wanted to add little descriptions of the links to other sites. Nobody really cares about links to “Chuck, Rich, Mary, George, and Dex the Tank,” but if the link said, “Chuck - owner of 12 chains of Dairy Queen,” you might be inclined to read about what goes on in the mind of a Dairy Queen owner. Anyway, I tried to set up some formatting using the Wordpress admin as shown below, but they didn’t seem to do anything:

Turns out the method get_links_list() in ~/wp-includes/links.php calls get_links(), but with hard-coded values for before, after, and between. The data wasn’t even being read from the database, so I added three columns, text_before_link, text_after_all, and text_after_link to the select statement and passed them into get_links(). Voila! Code is below:
// Fetch the link category data as an array of hashes
$cats = $wpdb->get_results(”
SELECT DISTINCT link_category, cat_name, show_images,
show_description, show_rating, show_updated, sort_order,
sort_desc, list_limit, text_before_link, text_after_link,
text_after_all
FROM `$wpdb->links`
LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
WHERE link_visible = ‘Y’
AND list_limit <> 0
ORDER BY $cat_order $direction “, ARRAY_A);
…// Call get_links() with all the appropriate params
get_links($cat[’link_category’],
//original hard-coded values
//’[li]’,”[li]”,”\n”,
$cat[’text_before_link’],
$cat[’text_after_all’],
$cat[’text_after_link’],
bool_from_yn($cat[’show_images’]),
$orderby,
bool_from_yn($cat[’show_description’]),
bool_from_yn($cat[’show_rating’]),
$cat[’list_limit’],
bool_from_yn($cat[’show_updated’])
);



0 Responses to “nerd shit wordpress style”