現在位置: Top/WordPressの改造

WordPressの改造

個別記事のリンクをMovableTypeと同じにする

  1. wp-includes/template-functions-links.phpを編集する
    29行目
    $rewritereplace = 
    array(
    	date('Y', $unixtime),
    	date('m', $unixtime),
    	date('d', $unixtime),
    	date('H', $unixtime),
    	date('i', $unixtime),
    	date('s', $unixtime),
    	$post->post_name,
    	$post->ID,
    	$category,
    	$author,
    	$post->post_name,
    );
    のなかの
    $post->ID,
    sprintf("%06d",$post->ID),
    とする。
  2. パーマリンクの設定
    「オプション」→「パーマリンク設定」
    「独自表記を以下の入力欄に記述」を選択し、
    「カスタム構造」に
    /archives/%post_id%.html
    と入力する。
  • ゼロでパディングされた記事番号のリンクが生成されますが、ゼロのまま値を渡しても記事番号として認識します。

MovableTypeからの移行

記事番号も保持したまま移行するには

  1. 書き出しに記事番号を付加する
    mt2\lib\MT\App\CMS.pmの2986行目
    AUTHOR: <$MTEntryAuthor$>
    の次の行に
    POST_ID: <$MTEntryID$>
    を追加
  2. MovableTypeの管理画面から記事の書き出しをする
  3. WordPressで記事番号を受け取れるようにする
    wp-admin\import-mt.phpの231行目
    switch($key) {
    	case '':
    		break;
    の次の行に
    	case 'POST_ID':
    		$post_id = $value;
    		break;
    を追加
    295行目の
    	$post_id = $wpdb->get_var("SELECT ID ……
    をコメントアウト
    //	$post_id = $wpdb->get_var("SELECT ID ……
  4. import-mt.phpを実行してインポートする

コメントの投稿者のURLからFaviconを取得→表示

Favatarを組み込む。スタイルシートに以下を追加

img.favatar {width: 16px; height: 16px;}

記事をインポートしたときにピンを受け付けない設定になっていたとき

一括してピンをオープンにするMySQLのコマンド

update wp2_posts set ping_status='open'

RSSフィード

sidebar.php

<li><a href="<?php bloginfo('rss2_url'); ?>">RSS 2.0</a></li>
<li><a href="<?php bloginfo('atom_url'); ?>">Atom</a></li>

header.php

<link rel="alternate" type="application/rss+xml" title="RSS 2.0"
href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3"
href="<?php bloginfo('atom_url'); ?>" />

サイト簡易表記の対応方法

サイト簡易表記の対応方法(WordPress)

月別アーカイブの表記を日本語に

wp_includes/template-function-general.php
336行目

if ( $show_post_count ) {
// $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
$text = sprintf(__('%dN %s'), $arcresult->year, $month[zeroise($arcresult->month,2)]);
$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
} else {
// $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
$text = sprintf(__('%dN %s'), $arcresult->year, $month[zeroise($arcresult->month,2)]);
}

個別記事のタイトルに「Blog Archive」という文字が入ってしまう

wp_content/themes/xxx/header.php

<?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> 

を削除する