エディタ改変
Wordpress 補完
purplefish32/sublime-text-2-wordpress
SublimeTextの教科書で紹介されてるプラグインまとめ
http://qiita.com/maccotsan/items/f320036e19f8d3b798c1
関数群
is single 記事ページ
記事ページのチェック
is_page 固定ページ
固定ページのチェック
get_bloginfo
WordPressでサイトのURLを取得する方法を整理してみた。
is_active_sidebar
この条件分岐タグは、あるサイドバーが有効化されているかどうかを調べます。boolean 関数で、TRUE または FALSE が返されます。
ウィジェットが含まれたサイドバーは TRUE を、ウィジェットが含まれないサイドバーは FALSE を返します。
http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/is_active_sidebar
add_filter
// SharePlugin -> getBtnHtmlの呼び出し
add_filter('the_content', array( $shareButton, 'getBtnHtml' ));
function getBtnHtml( $html ) { ← the_content呼び出し時点のHTMLが引数で渡される
// HTMLごにょる
$html .= 'hogehoge'; // ← 末尾にhogehoge追加
return $html; // ← ここでHTMLのテキストを返さないと記事の内容が空になる
}
プラグイン説明
・ 関連記事 表示プラグイン → WordPressにレコメンド機能プラグイン「Where did they go from here?」を日本語化してインストールでPVアップ!
http://mono.3samurai.com/?p=635
・ サイドバーの記事数(投稿数)表示方法【WordPress】
http://www.tkoyama.com/archives/2618/
・ エディター 画面 調整プラグイン
TinyMCE Advanced
・ WP セキュリティ向上プラグイン
Wordfence Security
・ アクセス数の高い記事のリスト表示
WordPress Popular Posts
・ アカウントプロフィール画像編集用プラグイン
WP User Avatar
・ 記事ごとのキーワード、デスクリプションを設定できるプラグイン
WP SiteManager
関連記事
・ この記事を見てる人はこちら
・ タグで関連
どちらか確認
get_template_directory_uri();
有効化している テンプレート ディレクトリの URI を取得する。SSL が存在するかチェックする。
注意: 末尾にスラッシュ( / )は含まれません。
・ WordPressでサイト設計をする時に覚えておきたいポストタイプの特徴などいろいろ
http://webdesignrecipes.com/wireframe-with-wordpress-post-type/
// TODO あとで直す the_* と get_the_*の違いについて
$article = array();
// タイトル
$article['title'] = the_title();
// カテゴリ
$article['category'] = the_category();
// リンク
$article['link'] = get_the_permalink();
// 記事の抜粋
$article['excerpt'] = the_excerpt();
// 投稿のアイキャッチ
$article['thumb'] = the_post_thumbnail();
// 記事の本文
$article['content'] = the_content();
// ------ 未取得
// 公開日時
$article['date'] = the_time();
// タグ
$article['tags'] = the_tags( string $before = null, string $sep = ', ', string $after = '' );
// 記事作者
$article['author'] = the_author( string $deprecated = '', string $deprecated_echo = true );
・ WordPressのアイキャッチのサイズ指定色々
http://memocarilog.info/wordpress/theme-custom/3152
・ 第8回 WordPressのモジュールテンプレートの種類と使い方を覚える
http://www.mdn.co.jp/di/articles/2782/?page=9
・ get_template_part
http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/get_template_part
・ get_the_tag_list
http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/get_the_tag_list
// タグがあったら → なければ丸ごと出力しない 前後のことを考えなくてよい
if ( get_the_tag_list() ) {
echo get_the_tag_list( '<ul><li>', '</li><li>', '</li></ul>' );
}
<?php $args = array(
'blog_id' => $GLOBALS['blog_id'],
'role' => '',
'meta_key' => '',
'meta_value' => '',
'meta_compare' => '',
'meta_query' => array(),
'include' => array(),
'exclude' => array(),
'orderby' => 'login',
'order' => 'ASC',
'offset' => '',
'search' => '',
'number' => '',
'count_total' => false,
'fields' => 'all',
'who' => ''
); ?>
・ get_the_category_list カテゴリリストの取得
http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/get_the_category_list
・ WordPress でユーザーのアバター画像 の URL のみを取得する方法
http://onepro.jp/get_avatar/
・ the author
http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/the_author
・ the_author_meta
http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/the_author_meta
・ 人気記事表示プラグイン「WordPress Popular Posts」を好きなHTMLで表示させよう
http://mbdb.jp/hacks/wordpress-popular-posts-customhtml.html
if (function_exists('wpp_get_mostpopular')) {
wpp_get_mostpopular(array (
'order_by' => 'views',
'limit' => 5,
'range' => 'daily',
'post_type' => 'post',
'wpp_start' => '<nav class="popular-area"><p class="title"><span>人気のエントリー</span></p><ul>',
'wpp_end' => '</ul></nav><!-- /.popular-area -->',
'post_html' => '<li><a href="{url}">{thumb}<span>{text_title}</span></a></li>',
'stats_comments' => 0,
'thumbnail_width' => 250,
'thumbnail_height' => 151,
));
}
WordPress Popular Posts Parameter
WP setting → WordPress Popular Posts → Parameters 参照
WP-CLI Advent Calendar 2014
http://www.adventar.org/calendars/505
[WordPress]wp_head()のいらないタグを削除してをスッキリさせる方法
http://techmemo.biz/wordpress/wp_head-delete-waste/
CSS、JSの読み込みは 自作テーマの中のfunctions.phpからつけたり消したりする
http://hijiriworld.com/web/wordpress-loop/
WordPressのループの仕組みを深く知る query_posts() と get_posts() の違い
【WordPress】記事本文のみ(画像などは無視)を、指定文字数だけ抜粋して表示する方法
http://gomokuankake.com/2013/01/19/2847/
WordPress:記事抜粋を表示するthe_excerptの使い方とカスタマイズのまとめ
http://pressstocker.com/the-excerpt/
記事 テキストのみ取得で文字数を制限して取得する
// ----------------- get_the_excerpt
// 記事の抜粋を取得したときに200文字まで取得
function new_excerpt_mblength($length) {
return 200;
}
add_filter('excerpt_mblength', 'new_excerpt_mblength');
// 記事の抜粋を取得したときに末尾に何の文字を追加するか
function new_excerpt_more($more) {
return '';
}
add_filter('excerpt_more', 'new_excerpt_more');
// なん文字取得するか引数で渡して記事から文字取得
function my_get_the_excerpt($num) {
return mb_substr(get_the_excerpt(), 0, $num);
}
ページング
paginate_links
http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/paginate_links
[解決済み] ページでページングを利用したい (7 件の投稿)
https://ja.forums.wordpress.org/topic/127
テンプレートタグ/posts nav link
http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/posts_nav_link
リダイレクトルールについて
WordPressで作成者(投稿者)アーカイブを作らない方法(リライトルールの勉強)
http://gatespace.jp/2012/05/10Th6/author-archive-rewrite-rule/
関数リファレンス/WP Rewrite
http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/WP_Rewrite
翻訳テキストを取得する __()
サンプル
WordPress のよくあるカスタマイズコード functions.php 多め
http://webdesignrecipes.com/wordpress-customize-with-functions-php/
22の WordPress カスタマイズ ハック
http://webdesignrecipes.com/22-wordpress-customize-hack/
input type imageの座標送信問題
で送信すると、X,Y座標が送信されるので、調べたら闇だった
http://takuya-1st.hatenablog.jp/entry/2014/12/05/145944
func
has_post_thumbnail
http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/has_post_thumbnail
管理画面カスタマイズ
【WordPress】ユーザーのプロフィールの項目をカスタマイズする
https://www.softel.co.jp/blogs/tech/archives/2919
定数 変数
固定ページの パーマリンク設定
プロが選ぶ!WordPressプラグインおすすめ50選【2015年版】
ユーザープロフィールの項目のカスタマイズ
/**
* ユーザープロフィールの項目のカスタマイズ
*/
function my_admin_user_meta($userData)
{
// 使っていない項目の削除
unset($contactmethods['aim']);
unset($contactmethods['jabber']);
//項目の追加
$userData['twitter'] = 'Twitter';
$userData['facebook'] = 'Facebook';
$userData['occupation'] = '肩書';
return $x;
}
add_filter('user_contactmethods', 'my_admin_user_meta', 10, 1);
function my_custom_popular_posts_html_list( $mostPopular, $instance ){
$output = '';
foreach( $mostPopular as $popular ) {
$stats = array(); // placeholder for the stats tag
var_dump($popular);
exit;
}
// return で返した値が即時表示
return $output;
}
add_filter( 'wpp_custom_html', 'my_custom_popular_posts_html_list', 10, 2 );
// dumpの出力結果
object(stdClass)#2217 (5) {
["id"]=> // 記事ID
string(3) "123"
["title"]=>
string(73) "記事のタイトル"
["date"]=>
string(19) "2015-02-09 00:35:44"
["uid"]=> // author ID
string(1) "2"
["pageviews"]=> // ページ表示回数
string(1) "2"
}
・ WordPress Popular Postsの出力をフルカスタマイズするには。
http://daidai.jp/wordpress-popular-posts-full-customize/
・ 3. Filters · cabrerahector/wordpress-popular-posts Wiki
https://github.com/cabrerahector/wordpress-popular-posts/wiki/3.-Filters
// 管理画面メニューの順番の変更
<?php
/**
* メニューの順番を変更
*/
function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php', // ダッシュボード
'separator1', // 最初の区切り線
'edit.php?post_type=member', // メンバー
'upload.php', // メディア
'edit.php?post_type=page', // 固定ページ
'separator2', // 二つ目の区切り線
//'themes.php', // 外観
'plugins.php', // プラグイン
'users.php', // ユーザー
'tools.php', // ツール
'options-general.php', // 設定
'separator-last', // 最後の区切り線
);
}
add_filter('custom_menu_order', 'custom_menu_order'); // Activate custom_menu_order
add_filter('menu_order', 'custom_menu_order');
?>
【サイト運営者必見】脅威のサイト丸ごと盗用プログラム現る!その手口と対策、受けた被害についてまとめました
http://estpolis.com/2015/02/17197.html
WP-BAN
https://wordpress.org/plugins/wp-ban/
Function Reference/plugins url
https://codex.wordpress.org/Function_Reference/plugins_url
・ WordPressでユーザがログイン中かどうか判定して表示内容を変える方法
http://staku.designbits.jp/wp-is-current-user-login/
WordPressのエラー処理 WP_Error クラスの使い方
https://firegoby.jp/archives/4175
How to create a custom button for the visual editor that adds 4 non-breaking spaces? (plugin or simple code)
http://wordpress.stackexchange.com/questions/37798/how-to-create-a-custom-button-for-the-visual-editor-that-adds-4-non-breaking-spa
WP_Error::get_error_code ()
https://developer.wordpress.org/reference/classes/wp_error/get_error_code/
Settings API
http://wpdocs.sourceforge.jp/Settings_API
WordPressのプラグインを作る際に覚えておくと便利な関数まとめ
http://blog.nully.org/2011/11/30/useful-function-for-wordpress-plugin/
TinyMCE Templates – ページや記事のテンプレートを作成するプラグイン
https://firegoby.jp/wp/tinymce_templates
初歩からわかるWordPressのnonceでAjaxをセキュアに実装する方法
WordPressでAjaxを使う方法の解説
WordPress の各種ディレクトリへのパスを取得するタグまとめ
http://weble.org/2011/02/18/wordpress-get-path-summary
無地のキホンテンプレート
underscores.me
"
wordpress ajax
条件分岐タグ
http://wpdocs.osdn.jp/%E6%9D%A1%E4%BB%B6%E5%88%86%E5%B2%90%E3%82%BF%E3%82%B0
WordPressの初期カテゴリー「未分類」を消す
http://www.loconoco.info/?p=1033
投稿設定 → メール投稿用カテゴリーの初期設定 → 別のものを設定
→ デフォルトのカテゴリが削除可能になっているので削除
2013年12月09日 もう迷わない!アーカイブページで現在のカテゴリ・タグの情報を簡単に取得する方法【WordPress】
http://blog.ks-product.com/wrodpress-get-current-term/
テキスト中の shortcodeを認識して返す
do_shortcode();
150901_1531_追記
デフォルトのパーマリンクで運用しているとWordfenceのユーザー記事一覧機能をOFFにする機能がつくようになりました。
Wordpress管理画面 → サイドメニューWordfence → options →
Prevent discovery of usernames through '?/author=N' scans のチェックを外す