Skip to content

Instantly share code, notes, and snippets.

Keisuke Imura funteractive

Block or report user

Report or block funteractive

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hatebu-crawl.js
var Request = require('request');
var Moment = require('moment');
var FeedParser = require('feedparser')
// config
var username = process.argv[2];
var baseUrl = 'http://b.hatena.ne.jp/' + username + '/';
var rssUrl = 'rss';
var baseYear = parseInt(process.argv[3]);
@funteractive
funteractive / functions.php
Created Nov 7, 2013
外部jsファイルの読み込み
View functions.php
<?php
function print_my_scripts(){
if( !is_admin() ){
wp_enqueue_script( 'script', get_stylesheet_directory_uri() . '/shared/js/script.js' );
}
}
add_action( 'wp_footer', 'print_my_scripts' );
@funteractive
funteractive / functions.php
Created Nov 7, 2013
組み込みのjQueryを外してGoogle APIのjQueryを読み込む
View functions.php
<?php
function load_cdn() {
if ( !is_admin() ) {
wp_deregister_script( 'jquery' );
wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', 'jquery' );
}
}
add_action( 'init', 'load_cdn' );
@funteractive
funteractive / header.php
Created Nov 6, 2013
一般的なWordPressの<title>タグ
View header.php
<title><?php echo( wp_title( ' | ', true, 'right' ) ); bloginfo( 'name' );?></title>
@funteractive
funteractive / functions.php
Created Oct 31, 2013
pre_get_postsでクエリーを変更するひな形
View functions.php
<?php
function custom_query( $wp_query ){
if( !is_admin() && $wp_query->is_main_query() && $wp_query->is_post_type_archive( 'title' ) ){
$wp_query->set( 'posts_per_page', 12 );
}
}
add_filter( 'pre_get_posts', 'custom_query' );
@funteractive
funteractive / functions.php
Created Oct 30, 2013
スラッグからpostオブジェクトを取得
View functions.php
<?php
function get_post_by_slug( $post_name, $post_type = 'post' ){
$args = array(
'name' => $post_name,
'post_type' => $post_type,
'posts_per_page' => 1
);
$the_post = get_posts( $args );
$the_post = $the_post[0];
@funteractive
funteractive / functions.php
Created Oct 29, 2013
読み込むテンプレートを変える。例は著者ページでhome.phpを読み込む場合。
View functions.php
<?php
function change_default_template( $template ){
if( is_author() ){
$template = get_home_template();
}
return $template;
}
add_filter( 'template_include', 'change_default_template' );
@funteractive
funteractive / functions.php
Created Oct 25, 2013
管理画面で設定した日付+時刻のフォーマットを取得
View functions.php
<?php
function get_option_datetime_format(){
$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );
$format = $date_format . ' ' . $time_format;
return $format;
}
@funteractive
funteractive / script.js
Created Jun 8, 2013
On jQuery like "foreach".
View script.js
$.each(object, function(index, value) {
console.log(value);
});
@funteractive
funteractive / functions.php
Created Jun 7, 2013
Display template name on front page of WordPress
View functions.php
<?php
add_filter( 'template_include', 'template_debug' );
function template_debug( $template ){
var_dump( $template );
exit;
}
You can’t perform that action at this time.