WordPessカスタマイズメモ
今回あるWebサイト作成にあたり、logwでは使っていなかったWordPressの技術をやってみようと思いました。今行っているカスタマイズのメモになります。
アイキャッチ画像の追加
新しいサイトではアイキャッチ画像を使っていこうと思いました。アイキャッチ画像の追加は以下のようにしました。
//アイキャッチ画像設定
add\_theme\_support( 'post-thumbnails' );
set\_post\_thumbnail\_size( 530, 250, false );//横幅530px×縦幅250pxの画像
falseを指定しているのでサイズオーバーだった場合は縮小ひょうじになります。
文字の数を指定して続きを読む表示
//抜粋
function new\_excerpt\_mblength($length) {
return 10;
}
add\_filter('excerpt\_mblength', 'new\_excerpt\_mblength');
function new\_excerpt\_more($post) {
return '<br />' . '<a href="'. get\_permalink($post->ID) . '" class="read\_more">' . '続きを読む' . '</a>';
}
add\_filter('excerpt\_more', 'new\_excerpt\_more');
10文字以上になったら「続きを読む」ボタンを表示しています。
ログイン画面のカスタマイズ
/\*------------------------------------
3.ログイン画面のカスタマイズ
------------------------------------\*/
//管理画面
function custom\_login\_logo() {
echo '<style type="text/css">h1 a { background: url('.get\_bloginfo('template\_directory').'/images/login/login\_logo.png) 50% 50% no-repeat !important; }</style>';
}
add\_action('login\_head', 'custom\_login\_logo');
function custom\_login() {
echo '<link rel="stylesheet" type="text/css" href="'.get\_bloginfo('template\_directory').'/css/login.css" />';
}
add\_action('login\_head', 'custom\_login');
ログイン画面のロゴを作ったサイトのにしています。そしてログイン画面の背景を変えるためにlogin.cssを作り読み込む設定にしています。