記録しながら作ろうと思っていたのに、あっという間に出来上がってしまった。
それでも、躓きつまづき、「エラー&エラー」の嵐に泣きながら。
だけど、改めて一からやってみて色々再確認できて良かった。
functions.phpに書いているもの
今のところ、これだけのことを書いています。
まだ、色々出てくるだろうけど基本の所は抑えてるかな?
追記
2013/10/7にプラグインpost snippetsを導入して、ショートコードをサイドバーで使用するようにしたので、
”//ショートコードをウイジェットでも使えるように
add_filter(‘widget_text’, ‘do_shortcode’);”
を追記しています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
<?php // メインコンテンツの幅を指定 if ( ! isset( $content_width ) ) $content_width = 650; // RSS2 の feed リンクを出力 add_theme_support( 'automatic-feed-links' ); // アイキャッチを有効化 add_theme_support( 'post-thumbnails' ); //ショートコードをウイジェットでも使えるように add_filter('widget_text', 'do_shortcode'); // カスタムメニューを有効化 add_theme_support( 'menus' ); // カスタムメニューの「場所」を設定 register_nav_menu( 'header-navi', 'ヘッダーのナビゲーション' ); // カスタムヘッダーの設定 $custom_header_params = array( 'default-image' => get_bloginfo('template_url').'/images/default-image.jpg', 'random-default' => true, //ランダム表示 'width' => 1000, 'height' => 300, 'flex-height' => false, //フレキシブル対応(高さ) 'flex-width' => false, //フレキシブル対応(幅) 'uploads' => true //ファイルアップロードを許可する ); add_theme_support( 'custom-header', $custom_header_params ); // カスタム背景の設定 $custom_background_defaults = array( 'default-color' => 'fff', 'default-image' => get_bloginfo('template_url') . '/images/default-back.jpg', ); add_theme_support( 'custom-background', $custom_background_defaults ); // カテゴリーIDの取得(カテゴリー別ランキング用) add_action('wp_head', 'get_current_category'); function get_current_category() { global $_curcat; $cate = null; if( is_category() ) { //カテゴリー表示だったら $cat_now = get_the_category(); // 親の情報を$cat_nowに格納 $cate = $cat_now[0]; } else if (is_single() ) { //シングルページ表示だったら $cates = get_the_category(); $i = 0; $use_category = 0; foreach ($cates as $cate) { //未分類を除外した配列の一番初めのカテゴリを選択 if($cate->category_parent > 0 && $use_category == 0) { $use_category = $i; } $i++; } $cate = $cates[$use_category]; } //カテゴリーのオブジェクトごと保持 $_curcat = $cate; return $cate; } // サムネイルを追加 add_image_size( 'side_thumbnail', 80, 80, true ); //ページネーションを追加 function pagination($pages = '', $range = 4) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) { echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>"; if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>"; if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>"; for ($i=1; $i <= $pages; $i++) { if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) { echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>"; } } if ($paged < $pages && $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>"; if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>"; echo "</div>\n"; } } // サイドバーウィジットを有効化 register_sidebar( array( 'name' => 'サイドバーprimary', 'id' => 'sidebar-primary', 'description' => 'サイドバーのウィジットエリア1です。', 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => 'サイドバーsecondary', 'id' => 'sidebar-secondary', 'description' => 'サイドバーのウィジットエリア2です。', 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'Before-content Widget Area', 'ari' ), 'id' => 'before_content-widget-area', 'description' => __( 'メインエリアの上です。' ), 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'After-content Widget Area', 'ari' ), 'id' => 'after_content-widget-area', 'description' => __( 'メインエリアの下です。' ), 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'After-singler Widget Area', 'ari' ), 'id' => 'after_singler-widget-area', 'description' => __( 'シングルエリアの下です。' ), 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'adsense Widget Area', 'ari' ), 'id' => 'adsense-widget-area', 'description' => __( 'アドセンス用です。' ), 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'photo Widget Area', 'ari' ), 'id' => 'photo-widget-area', 'description' => __( 'フォト表示用です。' ), 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'popular Widget Area', 'ari' ), 'id' => 'popular-widget-area', 'description' => __( '人気記事用です。' ), 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'index Widget Area', 'ari' ), 'id' => 'index-widget-area', 'description' => __( 'トップページの下です。' ), 'before_widget' => '<div id="%1$s" class="widget-container %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); /* Returns a "Continue Reading" link for excerpts */ function ari_continue_reading_link() { return ' <a class="continued" href="'. get_permalink() . '">' . __('つづきをよむ・・・' ) . '</a>'; } /* the_excerpt() [...]を消す */ function new_excerpt_more($more) { return ''; } add_filter('excerpt_more', 'new_excerpt_more'); /* head内にjsを読みこむ */ if(!is_admin()){ function register_script(){ wp_register_script('smoothscroll', get_bloginfo('template_directory').'/js/smoothscroll.js'); } function add_script(){ register_script(); wp_enqueue_script('smoothscroll'); } add_action('wp_print_scripts','add_script',10); } /* ダッシュボード関連 */ function remove_footer_admin () { echo 'お問い合わせは<a href="http://nekomoriya.biz/contact" target="_blank">ねこもりや</a>まで'; } add_filter('admin_footer_text', 'remove_footer_admin'); ?> |
導入した基本プラグイン
AddQuicktag:タグ入力を簡単に(しかし、ビジュアルエディタに表示されないという不具合発生中!)
AddThis Social Bookmarking Widget:SNSシェアボタンの導入
Adminimize:編集者用にメニューやダッシュボードをカスタマイズ
Akismet:スパム対策
Auto Post Thumbnail:アイキャッチ画像を自動で
Crazy Bone (狂骨):不審なログインを監視(するだけ)
Delete-Revision:リビジョンを削除
Disable Revisions and Autosave:リビジョンを制御
Easy FancyBox:画像をLightBoxみたいなエフェクトでExec-PHP:ウイジェットにもPHPが書ける
追記
post snippets:Exec.PHPを使わずにショートコードを書く
2013/10/7現在以下の様にExec.phpを使わない選択をしました。
WordPressプラグインEXEC-PHPを使わずにウイジェットにショートコードを使うことにした経緯。追記あり

>>なぜexec-PHPがモテるのか | WP-D EXEC-PHPって危険なの? わかりません(ねこもりやには)。 って、でも、Wordpressを自動インストールして、無料配布のテンプレート使ってブログ書いてる
EZ zenback:これもSNSシェアボタンだけどそれ以上に、アクセス増を・・・
Google XML Sitemaps:巡回ロボット用のサイトマップ作成
Link Manager:最近無くなったリンクパネルを再現
Maintenance Mode:メンテナンス時用に
Regenerate Thumbnails:サムネイルを再作成
Resize At Upload Plus:アップロードのサイズを制限
Ultimate Google Analytics:アナリティクスの設定用
WordPress Head Cleaner:ヘッダーをきれいに?
WordPress Popular Posts:人気の記事を表示
WP-DBManager:データベースのバックアップ
WP Multibyte Patch:マルチバイト関連の問題に対処
Yet Another Related Posts Plugin :関連記事を表示
追記
2013/9/29 以下もご参考に。
WordPressでdownload-managerプラグインをインストールしてる時、ページネーションとCSSがかぶっちゃうらしいので対処。

昨日、気が付いたんだけど・・・ 先日の投稿で「functions.phpに書いたものとして公開したページネーションを実装するときの記述」。そのままだと、どうやらDownload Managerプラグインのクラスと被るらしく、CSS(ス