tadhg.com
tadhg.com
 

Posts concerning WordPress

Twitter Experimentation

18:00 12 Feb 2009

After refusing for quite some time, I’ve decided to give Twitter a try. This might prove short-lived, but we’ll see. I like the concept of easy status updates and of disconnecting them from a larger, clunkier framework, e.g. Facebook.
[more...]

Permalink     4 Comments     [, , , , ]    

Related Posts Plugin and SQL Trickery

11:55 10 Feb 2009
Permalink     4 Comments     [, , , , ]    

New Blog Functionality: Related Posts

23:37 01 Feb 2009. Updated: 16:31 10 Feb 2009

Having revived my proper blog and transferred my content over, I’ve now started adding improvements, some of which I’ve been wanting to add for quite some time. The first one is a list of related posts on the individual post pages.
[more...]

Permalink     Comment     [, , ]    

Blog Move Steps, Part Three: DNS Change

23:58 27 Jan 2009. Updated: 01:13 30 Jan 2009

I’ve wrangled my old plugins and custom code so that it mostly works, except for one or two features (such as “related posts” based on tags) that I’ll revive later. Good enough for now, so I’m making the DNS changes and going ahead.

If you’re seeing this text, you’re on the new server, and all should be well. But if you don’t see another post after this one by about Friday, it suggests RSS problems, so please drop me a line.

Permalink     1 Comment     [, , ]    

Blog Move Steps, Part Two

22:30 26 Jan 2009. Updated: 16:46 28 Jan 2009

I continued working on the blog move today, and most of the tricky database-related steps are done.
[more...]

Permalink     Comment     [, , ]    

Blog Move Steps, Part One

23:53 25 Jan 2009. Updated: 16:46 28 Jan 2009

I spent time today working on moving this blog to a new home, while also combining the articles from the old (real) blog and from this temporary one, and upgrading my version of WordPress in the process.
[more...]

Permalink     Comment     [, , ]    

RSS Borkage

23:58 10 Jul 2008. Updated: 18:14 28 Jan 2009

Apparently, my blog’s RSS feeds were set up incorrectly in the WordPress 2.0 version that I run, and I shouldn’t have been pointing directly to the files in the wp directory, but instead to /wp/feed. With my temporary version running WP 2.5, the functionality of those deprecated links was removed—but they still existed, merely returning blank feeds.

That should be fixed now. The most important article that people might have missed was probably the speech I gave at my father’s funeral, available for those who couldn’t make it in person.

Permalink     Comment     [, , ]    

Simple WordPress Anti-Spam Plugin

23:53 09 Feb 2007. Updated: 02:05 10 Feb 2007

I created a simple anti-spam plugin for WordPress—all it does is reject comments from unregistered users which have more than some number of links in them.
[more...]

Permalink     Comment     [, , ]    

Installing WordPress 2.0

18:06 21 Jan 2006. Updated: 14:16 25 Mar 2006

Steps to installing:

  • Follow the 5-minute installation plan from the docs.
  • Start editing my own theme (start from default).
  • First file: header.php.
  • Second file: index.php.
  • Add UltimateTagWarrior.
  • Enable Permalinks (including enabling mod_rewrite in httpd.conf and turning on AllowOverride All and Options FollowSymLinks in the VirtualHost block, and temporarily making .htaccess world-writable).
  • Enable tag rewrites in UltimateTagWarrior, use commalist for displaying the tags after the articles.
  • Comment out add_filter(‘the_content’, ‘wpautop’); in wp-includes/default-filters.php to stop WordPress from adding its own HTML to my posts
  • Add post_updated plugin to show update time of posts. added this linke to The_Loop: <?php post_updated(‘H:i d M Y’, 0, ‘, <span class=”timestamp”>updated: ‘, ‘</span>’); ?>
  • In progress: Add an archive index following instructions here: http://codex.wordpress.org/Creating_an_Archive_Index
  • In progress: figure out how to link to random “articles” and later to book db
  • In progress: edit single.php to bring it into the current design
    • This included figuring out how to get UTW to display the other posts with the current tags, which wasn’t easy due to my unfamiliarity with OOPHP. Eventually, I instantiated a variable ($currentID) outside of The_Loop, then got its value using $currentID = $post->ID; in The_Loop, and finally $tagset = $utw->GetTagsForPost($currentID); $posts = $utw->GetPostsForTags($tagset); for the array of posts with those tags.
    • I borrowed the following for an initial pass at display:
      if (count($posts)) {
      echo ‘<h2>Listings for ‘ . implode(“, “, $posts) . ‘</h2><ul>’;
      $cnt = 0;
      foreach ($posts as $post) {
      if (++$cnt > 10) break;
      setup_postdata($post);
      echo ‘<li><a href=”‘;
      echo the_permalink();
      echo ‘”>’. $post->post_title.’</a></li>’;
      }
      echo ‘</ul>’;
      }
    • I also set up a different sidebar file, sidebar_single.php, to hold the code for the sidebars on individual pages.
    • In ultimate-tag-warrior-core.php, change part of GetPostsForTags from ORDER BY t.tag ASC to ORDER BY p.post_date DESC
    • Add code to header.php to get category of posts and apply corresponding banner images (category will not be used for searching/navigation, but purely for determining what ‘template’ should be used. Right now, I think that posts should have only one category, but that might change.
  • Enable RSS feeds; add CDATA tags around content for wp-rss.php. This turned into a bigger problem, one that required me to hard-code the UTF-8 encoding into the feed files, because if I allowed require_once() calls before the echo outputting the XML declaration, PHP put a line break in there that caused the feeds not to validate. So I had to move the if (empty($wp)) { require_once(‘wp-config.php’); wp(‘feed=rss’);} stuff below the echo in the initial code block, and remove the get_settings(‘blog_charset’) in header and echo lines, replacing it with hardcoded ‘UTF-8′. Files altered: wp-rss.php, wp-rss2.php, wp-rdf.php, wp-atom.php.
  • Make the RSS 1 excerpt length longer–change <description><![CDATA[<?php the_content_rss('', 0, '', get_settings('rss_excerpt_length'))?>]]></description> to <description><![CDATA[<?php the_content('', 0, '') ?>]]></description> (Note–I haven’t yet tested this in RSS readers, so the rss 0.92 feed might still be broken).
  • Add Markdown for blog entry
  • Add “WP Unformatted” plugin to turn off ‘smart quotes’ on a per-post basis, to ensure that e.g. JavaScript bookmarklets come through correctly.
  • TODO: make the ‘read more’ text invisible if the post doesn’t have any more than what is shown
  • To add “summary” support, use a custom field—the_excerpt() isn’t good enough because it’s too tough to conditionally use either the excerpt or something else. The custom field is summary, and the code inside the post div on an index/archive page is:
    <?php
    $postID = $post->ID;
    $summary = get_post_meta( $post->ID, ‘summary’, true );

    if ($summary != “”)
    {
    ?>
    <div class=”excerpt”><?php echo($summary); ?><br />
    <a href=”<?php the_permalink(); ?>”><b>[Read article]</b></a>
    </div>

    <?php
    }
    else
    {
    ?>

    <div class=”excerpt”><?php the_content(‘<b>[more...]</b>’) ?></div>
    <?php
    }
    ?>
    <div class=”article_trailer”><a href=”<?php the_permalink(); ?>”>Permalink</a>     <?php comments_popup_link(‘Comment’, ’1 Comment’, ‘% Comments’); ?>     [<?php UTW_ShowTagsForCurrentPost("commalist") ?>]     <?php edit_post_link(‘Edit’, ”, ”); ?></div>

    Except that this didn’t work on the tag archive page (tag.php), because $post->id simply refused to work there, requiring me to get the post id with: global $id instead.

  • To add “sidenote” support, add the following to single.php:
    <?php
    $sidenote = get_post_meta( $post->ID, ‘sidenote’, true );

    if ($sidenote != "")
    {
    ?>
    <div id="sidenote"><?php echo($sidenote); ?></div>

    <?php
    }
    else
    {
    ?>

    <?php
    }
    ?>

    And then add sidenote fields as custom fields when creating posts as necessary.

  • To add support for per-post custom css, add the following to header.php:

    <?php
    $custom_stylesheet = get_post_meta( $post->ID, ‘custom_stylesheet’, true );

    if ($custom_stylesheet != "")
    {
    ?>
    <link rel="stylesheet" href="<?php echo($sidenote); ?>" type="text/css" media="screen" />
    <?php
    }
    else
    {
    ?><?php
    }
    ?>

    And then add custom_stylesheet as a custom field to posts where necessary.

Permalink     1 Comment     [, ]