Installing WordPress 2.0
.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.