Skip to content

Instantly share code, notes, and snippets.

@hykw
hykw / gist:85860e7e9b5bfdd113d6
Last active August 29, 2015 14:03
wordpress: 相対パスでのwp-load.phpの読み込み方
$wpload = sprintf('%s/wp-load.php', $_SERVER['DOCUMENT_ROOT']);
require_once($wpload);
@hykw
hykw / gist:a78d1a28155d47768986
Last active May 24, 2016 09:07
wordpress: WP_Query() 呼び出し例
$args = array(
'post_type' => array(
'post',
),
'post_status' => array(
'publish',
),
'posts_per_page' => 5,
'order' => 'DESC',
'orderby' => 'date',
@hykw
hykw / gist:f62244c4fe1924ecfd6d
Last active August 29, 2015 14:04
wordpress: 固定ページでページング
■コンテンツ側
<!--nextpage-->
■php側
<?php
# ページングタグを表示する所で設定
wp_link_pages();
--------
c.f.
@hykw
hykw / gist:27f9586f2e9af88afe56
Created July 18, 2014 09:44
wordpress: 投稿画面に注記を追加
function after_title() {
echo '<p>これはタイトル下に表示される</p>';
}
add_action( 'edit_form_after_title', 'after_title' );
function after_editor() {
echo '<p>これはエディタ下に表示される</p>';
}
add_action( 'edit_form_after_editor', 'after_editor' );
@hykw
hykw / gist:3e43d3e62d34bb7e718e
Created July 18, 2014 09:54
wordpress: 投稿画面の項目非表示
function remove_default_post_screen_metaboxes() {
remove_meta_box( 'tagsdiv-post_tag' , 'post' , 'side' ); /* 投稿のタグ */
}
add_action('admin_menu','remove_default_post_screen_metaboxes');
@hykw
hykw / gist:bb0a1d034b648c275643
Last active August 29, 2015 14:04
MySQL: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
/etc/my.cnf
-------------------------
default-character-set=utf8
character-set-server = utf8
collation-server=utf8_general_ci
init_connect='SET collation_database = utf8_general_ci; SET collation_connection = utf8_general_ci'
skip-character-set-client-handshake
-------------------------
mysql> ALTER DATABASE db CHARACTER SET utf8 COLLATE utf8_general_ci
@hykw
hykw / gist:a60acc3fbec3d55320c1
Created September 3, 2014 00:59
grep で tab 検索
grep $'\t'
@hykw
hykw / gist:65fb50edf11edf1cd9bc
Created September 4, 2014 06:30
wordpress: nonce
$nonce = wp_nonce_field('pagename', '_wpnonce', true, false);
<form>
{$nonce}
</form>
---------------------
if(is_page('pagename') && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'pagename')) {
#
} else {
@hykw
hykw / gist:2051d82ef2ec76869e03
Last active August 29, 2015 14:06
svnのcopy, merge, switch方法
svn copy trunk branches/hogehoge
svn commit
→ リビジョン12345とする
# 〜〜〜 branchで作業、最終リビジョンは22222
# BASEディレクトリにcd(svn mergeはパスを指定しないと作業ディレクトリを対象にしちゃうので)
cd ~/svn/hogeSVN
# 12345〜22222(≒ HEAD)の修正を trunk にマージ
@hykw
hykw / gist:158d4dc7d0419b771d77
Created October 21, 2014 01:38
htpassword の crypt 認証によるハッシュ生成
htpassword -d /tmp/passwd username