Skip to content

Instantly share code, notes, and snippets.

@Tenderfeel
Tenderfeel / custom_header_carousel.php
Last active March 2, 2018 08:55
Wordpressのcustom-headerの画像でカルーセル作る
var fs = require('fs'),
del = require('del');
gulp.task('clean', function(done) {
var files = fs.readdirSync('dist');
var targets = [];
if(files.length) {
targets.push('dist/*');
@Tenderfeel
Tenderfeel / get_category_custom_field.php
Created February 5, 2018 03:05
カテゴリー一覧で表示されている記事のカスタムフィールドの値を得る
/**
* カテゴリー一覧で表示されている記事のカスタムフィールドの値を得る
* @return Array カスタムフィールド値の配列
*/
function get_category_custom_field($cat_id) {
global $wpdb;
$meta_key = 'your_custom_field_key';
$limit = get_option('posts_per_page');
$offset = get_query_var('paged') * $limit;
@Tenderfeel
Tenderfeel / duration_time.js
Created November 8, 2017 05:51
ISO_8601 Durations(time) convert
function duration(str) {
var matches = str.match(/PT(\d*)H*(\d+)M*(\d+)S*/i);
var d = (matches[1] && matches[1] + ':'); //hour
d += (matches[1] && matches[2] < 10 ? '0' : '') + (matches[2] && matches[2] + ':'); //min
d += (matches[3] && matches[3] < 10 ? '0' : '') + (matches[3] && matches[3]); //sec
return d;
}
@Tenderfeel
Tenderfeel / get_category_posts_customfield_value.php
Last active October 31, 2017 10:18
Wordpressでカテゴリーに所属する記事に設定されている指定したカスタムフィールドの値をリスト形式で得る
<?php
/*
カテゴリーに所属する記事に設定されている指定したカスタムフィールドの値をリスト形式で得る
*/
function get_category_posts_customfield_value($cat_id, $meta_key) {
global $wpdb;
$limit = get_option('posts_per_page');
$offset = get_query_var('paged') * $limit;
@Tenderfeel
Tenderfeel / get_gategory_name_by_id.php
Created October 31, 2017 08:49
WordpressでカテゴリーIDからカテゴリー名を得る
<?php
$result = $wpdb->get_results($wpdb->prepare("
SELECT name
FROM $wpdb->terms AS tm
JOIN $wpdb->term_taxonomy AS tmt
USING(term_id)
WHERE tmt.taxonomy = %s
AND term_id = %d
", 'category', $cat_id));
@Tenderfeel
Tenderfeel / get_category_posts_data.php
Created October 31, 2017 08:19
Wordpress get_category_posts_data
<?php
/*
$cat_idで渡したカテゴリーIDに登録されている記事の情報を返す
返す情報はSELECTの内容に基づく(記事IDと記事タイトル)
参考:https://qiita.com/m-shin/items/cec1b8278448e70be168
get_category_posts_data(get_cat_ID(single_cat_title('', false)));
*/
function get_category_posts_data($cat_id) {
/**
* jQuery Pager plugin
* Licensed under the MIT license
* This plugin is refer to how to write "jQuery ScrollSpy Plugin".
*/
(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports !== 'undefined') {
@Tenderfeel
Tenderfeel / Compass flexbox mixin
Created September 8, 2017 05:59
compass-flexbox-shorthands.scss
//http://compass-style.org/reference/compass/css3/flexbox/
//http://jsdo.it/Tenderfeel/ofwd
@include flexbox((
display: box,
box-orient: vertical,
box-pack: justify,
box-align: start
), $version: 1);
@Tenderfeel
Tenderfeel / isIE.js
Created August 21, 2017 10:58
user agent check of IE
var isIE = (function() {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('msie') >= 0 || ua.indexOf('trident') >= 0) {
var array = /(msie|rv:?)\s?([\d\.]+)/.exec(ua);
return (array) ? array[2] : true;
} else {
return false;
}
}());