• I am using the ‘daily blog posting’ feature in del.icio.us. It sends a digest of all my del.icio.us bookmarks for the day and posts them on my blog (WP 2.5).

    The problem is, the titles that del.icio.us gives the daily blog posts are ugly – they look like this:

    Links for 05-22-2008

    I found a plugin that lets you change the title of the posts to whatever you like – it’s called ‘del.icio.us daily blog post fixer plugin’ (http://dougal.gunters.org/blog/2006/04/07/delicious-daily-blog-post-fixer-plugin).

    Now I can change the title to something like: ‘Today’s Del.icio.us Bookmarks’. That’s OK, but after a month I’ll have 30 posts all with identical titles.

    So, I’ve been trying to modify the plugin so that the titles also include the date. I want something like this:
    ‘Del.icio.us Bookmarks For 22 May 2008’

    Unfortunately my PHP skills are non-existent and my attempts so far have failed.

    Here is the code for the original plugin (including developer’s comments):

    // If we see a title of the form "links for 2006-03-14", rewrite it:
    function dp_title_change($text = '') {
    	/*
    	 * I could spend a lot of time adding an option screen in
    	 * the WP admin interface for this. But it's just one little
    	 * text string. So if you don't want your auto-posts to be
    	 * called "Daily Links", change it here:
    	 */
    	$mytitle = "Daily Links";
    
    	$text = preg_replace('/links for \d\d\d\d-\d\d-\d\d/', $mytitle, $text);
    
    	return $text;
    }
    
    // Add 'rel="tag"' to any del.icio.us tag links
    function dp_del_link_rel_tag($text = '') {
    	/*
    	 * Add rel="tag" to del.icio.us links.
    	 *
    	 * Once I realized that backslashes need to be escaped inside
    	 * of single-quoted strings, things got happy.
    	 */
    
    	$regex = '%<a (href=(?:\\\\)?"http://del\.icio\.us/[^/"]+/[^/"]+(?:\\\\)?")>([^<]+)</a>%';
    
    	$text = preg_replace($regex, "<a $1 rel=\"tag\">$2</a>", $text);
    
    	return $text;
    }
    
    // Tell WP to do some magic to the post title and content before
    // saving it into the db.
    add_filter('title_save_pre','dp_title_change');
    add_filter('content_save_pre','dp_del_link_rel_tag');

    So, I tried re-writing the dp_title_change function like this:

    function dp_title_change($text = '') {
    
    	$deltoday = mktime(0, 0, 0, date("m"), date("d"), date("y"));
    
    	$mytitle = ("Del.icio.us Bookmarks For ".date("j F Y", $deltoday));
    
    	$text = preg_replace('/links for \d\d\d\d-\d\d-\d\d/', $mytitle, $text);
    
    	return $text;
    }

    It doesn’t work (I told you I don’t know PHP!!) – the title just appears as a long number. For example, the title for 22 May is ‘1211432400’.

    Can anyone see a solution to this? How can I include the date in the titles?

Viewing 1 replies (of 1 total)
  • Yeah, change the line containing the $mytitle variable to this:

    $mytitle = "Del.icio.us Bookmarks For ".date("j F Y");

Viewing 1 replies (of 1 total)
  • The topic ‘Delicious daily links – change the title’ is closed to new replies.