書体指定(Font)

明朝
font-family:”ヒラギノ明朝 Pro W6″,”Hiragino Mincho Pro”,”HGS明朝E”,”MS P明朝”,”MS PMincho”,”MS Mincho”,serif;

ゴシック
font: 12px/1.5 “ヒラギノ角ゴ Pro W3″,”Hiragino Kaku Gothic Pro”,”メイリオ”,”Meiryo”,arial,Osaka,”MS Pゴシック”,”MS PGothic”,Sans-Serif;

ログイン画面のロゴ・CSS・リンク先を変更したい

[参考]http://codex.wordpress.org/Customizing_the_Login_Form

// ログイン画面ロゴ変更
function my_custom_login_logo() {
echo ‘

‘;
}
add_action(‘login_head’, ‘my_custom_login_logo’);

//ログインのロゴのリンク先変更
function custom_login_logo_link() {
return get_bloginfo( ‘home’ ).’/';
}
add_filter( ‘login_headerurl’, ‘custom_login_logo_link’ );

CSSを変更したい場合

.login h1 a {
background-image: url(‘../images/wordpress-logo.png?ver=20120216′);
background-size: 274px 63px;
background-position: top center;
background-repeat: no-repeat;
width: 326px;
height: 67px;
text-indent: -9999px;
overflow: hidden;
padding-bottom: 15px;
display: block;
}

必要に応じてfunction.phpから上書きが可能です。

画像の回り込み解除 CSS

WordPress の標準テーマである default, twentyten には
回り込みに関するスタイルが書いてあります。

/* 画像の回り込みとか */
.aligncenter {
    display: block;
    clear: both;
    margin: 0.25em auto 1.5em;
    }
.alignleft {
    float: left;
    clear: both;
    margin: 0.25em 1.5em 1.5em 0;
    }
.alignright {
    float: right;
    clear: both;
    margin: 0.25em 0 1.5em 1.5em;
    }
h2, hr {
    clear: both;
    }

配置:左が連続すると、回り込みがおかしくなってしまうので、
画像タグの後に

<div style="clear:both;"></div>

を挟むか、見出しか水平線を書けば回り込みを解除できます。

プラグイン 試したいもの

Post Templates
記事のひな形を作れるプラグイン、ECサイトの商品紹介ページなどに向いている?

Duplicate Post
記事を複製できる
[参考]http://blog.tk-works.info/duplicate-post-62.html
[参考]http://design-plus1.com/tcd-w/2013/02/duplicate_post.html

PS Disable Auto Formatting
とにかく、いっぱい改行入れたいプラグイン

WP-Cufon
フォントを画像と置き換える
[参考]http://mbdb.jp/hacks/plugin_wpcufon.html

Infinite-Scroll
記事一覧を無限スクロールに変更する

Exec-PHP
記事内でPHPを使えるようにする。が、一度入れると2度と外せない。
[参考]http://blog.quusookagaku.com/wordpress/9059/

WordPress Download Monitor
ダウンロードファイルを管理する
[参考]http://www.lasical.com/2011/01/18/614/

Simple Membership
WordPressで会員制サイトを作れる無料プラグイン
[参考]https://www.webcreatorbox.com/tech/simple-membership

投稿内に指定カテゴリーの記事を表示するショートコード

function.phpに

function show_Cat_Posts_func($atts) {
	global $post;
	$output = "";
 
	extract(shortcode_atts(array(
		'cat' => 1, // デフォルトカテゴリーID = 1
		'show' => 3 // デフォルト表示件数 = 3
	), $atts));
 
	$cat = rtrim($cat, ",");
	// get_postsで指定カテゴリーの記事を指定件数取得
	$args = array(
		'cat' => $cat,
		'posts_per_page' => $show
	);
	$my_posts = get_posts($args);
 
	// 上記条件の投稿があるなら$outputに出力、マークアップはお好みで
	if ($my_posts) {
		// カテゴリーを配列に
		$cat = explode(",", $cat);
		$catnames = "";
		foreach ($cat as $catID) : // カテゴリー名取得ループ
			$catnames .= get_the_category_by_ID($catID).", ";
		endforeach;
		$catnames = rtrim($catnames, ", ");
 
		$output .= '<aside class="showcatposts">'."\n";
		$output .= '<h2 class="showcatposts-title">カテゴリー「'.$catnames.'」'."の最新記事(".$show."件)</h2>\n";
		$output .= '<ul class="showcatposts-list">'."\n";
		foreach ($my_posts as $post) : // ループスタート
			setup_postdata($post); // get_the_title() などのテンプレートタグを使えるようにする
			$output .= '<li id="post-'.get_the_ID().'" '.get_post_class().'><a href="'.get_permalink().'">'.get_the_title()."</a></li>\n";
		endforeach; // ループ終わり
		$output .= "</ul>\n";
		$output .= "</aside>\n";
	}
	// クエリのリセット
	wp_reset_postdata();
	return $output;
}
add_shortcode('showcatposts', 'show_Cat_Posts_func');

投稿の編集画面に

[showcatposts cat="1" show="3"]

<参考>
http://gatespace.jp/2012/03/28/show_categoryposts_shortcode/
http://coliss.com/articles/blog/wordpress/wordpress-shortcodes.html

お引越し、サーバー移行方法の手順まとめ

参考 http://infinityforest.net/home/archives/2417 より

この方法は、URLの変更やDBの変更など何もなくそっくりそのまま移行する方法です。
ドメインの変更などがある場合この手順では足りない部分があります。

事前準備

◎新サーバーにWordPressを新規インストール

◎旧サーバのデータをエクスポート
 (エクスポートするデータは次の6つ)

・SQLデータ)wp_options 以外のテーブルを SQLデータでエクスポート)
・テーマフォルダ
・wp-content > uploads フォルダ内の画像
・wp-content > plugins フォルダ内(できるだけ最小限のプラグインだけアンインストール)
・ダッシュボード > ツール > エクスポート で、投稿記事などを全てエクスポート
・ダッシュボード内のテーマ設定している場合は、その入力データ全て(キャプチャー、コピー要)

◎新サーバへデータをインポート

・新サーバのデータベース全てをエクスポート(万が一間違って消しても何とかするために)
・新サーバのデータベースの、wp-options 以外のテーブルを空にする
・旧サーバからエクスポートしたSQLデータを、新サーバにインポート

◎新サーバへファイル等をインポート

・テーマフォルダ・・・ wp-content > themes
・フォルダに格納されているファイル(画像)・・・ wp-content > uploads
・プラグインフォルダ・・・ wp-content > plgins

◎確認する

海外テーマの文字化けを回避する

文字を短く区切った部分だけ、文字化けしちゃうのよね〜
マルチバイトのプラグインは有効化してるのに、
文末が◆に?の文字が入る所と入らない所がある。

と思って調べたら下記のサイトを発見!
http://zatzcan.com/wordpress/26.html

「function.php」や「tabs.php」などから以下のような記述を見つけ、
2バイト文字に対応したmb_substrに変更とのこと。

■修正前

$text = substr($text,0,$chars_limit);
$text = substr($text,0,strrpos($text,' '));

■修正後

$text = mb_substr($text,0,$chars_limit,'UTF-8');
$text = mb_substr($text,0,strrpos($text,' '),'UTF-8');

とはいえ、だいぶ書いてあるコードが違ったかも、と思ってメモメモ!

「functions.php」内の記述を修正

■修正前

function print_excerpt($length) {
	global $post;
	$text = $post->post_excerpt;
	if ( '' == $text ) {
		$text = get_the_content('');
		$text = apply_filters('the_content', $text);
		$text = str_replace(']]>', ']]>', $text);
	}
	$text = strip_shortcodes($text); 
	$text = strip_tags($text);

	$text = substr($text,0,$length);
	$excerpt = reverse_strrchr($text, '.', 1);
	if( $excerpt ) {
		echo apply_filters('the_excerpt',$excerpt);
	} else {
		echo apply_filters('the_excerpt',$text);
	}
}

function reverse_strrchr($haystack, $needle, $trail) {
    return strrpos($haystack, $needle) ? substr($haystack, 0, strrpos($haystack, $needle) + $trail) : false;
}

■修正後

function print_excerpt($length) {
	global $post;
	$text = $post->post_excerpt;
	if ( '' == $text ) {
		$text = get_the_content('');
		$text = apply_filters('the_content',
		$text); $text = str_replace(']]>', ']]>', $text);
	}
	$text = strip_shortcodes($text);
	$text = strip_tags($text);

	$text = mb_substr($text,0,$length,'UTF-8');
	$excerpt = reverse_strrchr($text, '.', 1);
	if( $excerpt ) {
		echo apply_filters('the_excerpt',$excerpt);
	} else {
		echo apply_filters('the_excerpt',$text);
	}
}

function reverse_strrchr($haystack, $needle, $trail) {
	return strrpos($haystack, $needle) ? mb_substr($haystack, 0, strrpos($haystack, $needle) + $trail,'UTF-8') : false;
}

ふ〜。長かった。
「substr」を「mb_substr」にして、’UTF-8’を追加するのを2箇所づつやっただけですが。
とりあえず、忘れないように・・・