Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
nishinoshake / oops.md
Last active May 29, 2016 04:16
switch_to_blogしてもカスタム投稿タイプは切り替わらない
@nishinoshake
nishinoshake / custom.txt
Created March 3, 2016 08:08
カスタムフィールドテンプレート
ACFよりも自由度が高い
グループ化とグループ追加ができる。
↓ここが詳しい
http://kotori-blog.com/wordpress/customfieldtemplate_add/
@nishinoshake
nishinoshake / mixin.scss
Last active May 29, 2016 04:17
mixinまとめ
@mixin min($width: 960px) {
@media only screen and (min-width: $width) {
@content;
}
}
@mixin max($width: 959px) {
@media only screen and (max-width: $width) {
@content;
}
@nishinoshake
nishinoshake / output_sass.sh
Last active May 29, 2016 04:18
SASSでファイル変更を監視してコンパイル
sass --style expanded --watch hoge.scss:hoge.css
@nishinoshake
nishinoshake / getThumbnail.php
Last active May 29, 2016 04:19
Wordpressでサムネイルがない場合はnoimage
function getThumbnailUrl() {
if ( get_post_thumbnail_id() ) {
$thumbnailUrl = wp_get_attachment_image_src(get_post_thumbnail_id(), true)[0];
} else {
$thumbnailUrl = get_template_directory_uri() . '/images/noimage.jpg';
}
return $thumbnailUrl;
}
@nishinoshake
nishinoshake / for.scss
Last active May 29, 2016 04:20
SASSのforでdelayずらし
@for $i from 0 through 11 {
ul li:nth-of-type(#{$i + 1}) { transition-delay: #{$i * 80ms};}
}
@nishinoshake
nishinoshake / readme.md
Last active May 29, 2016 04:20
WP_Queryの引数まとめ
@nishinoshake
nishinoshake / removeClassRegExp.js
Last active May 29, 2016 04:21
jQueryのremoveClassを正規表現で
$about.removeClass(function(index, className) {
return (className.match(/\bbg\d+/g) || []).join(' ');
});
@nishinoshake
nishinoshake / readme.md
Last active May 29, 2016 04:21
WordPressテンプレート作成

##WordPressテンプレート作成

###各ファイルの特徴 style.css
ここにテーマの情報も書く。メインのスタイル。

index.php
いろんなファイルがなかったら最後に参照されるファイル。

header.php

@nishinoshake
nishinoshake / judgeNew.php
Last active May 29, 2016 04:22
PHPで新しいかの判定
function judgeNew($postedDate) {
$past = 7; // 1 week
if ( strtotime($postedDate) >= strtotime('-' . $past . ' day') ) {
return true;
} else {
return false;
}
}