This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add post thumbnail to admin column. | |
*/ | |
// add product field admin column | |
function add_blog_admin_columns_head( $defaults ) { | |
$defaults[ 'post_thumbnail' ] = 'アイキャッチ画像'; | |
return $defaults; | |
} | |
add_filter( 'manage_blog_posts_columns', 'add_blog_admin_columns_head' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Count returned json array length. | |
# --graboff is for [] parameter. | |
curl --globoff https://private.hibou-web.com/wp-json/wp/v2/posts?filter[posts_per_page]=5 | jq length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "liottest", | |
"version": "1.0.0", | |
"description": "liot test", | |
"main": "index.js", | |
"scripts": { | |
"test": "start", | |
"start": "browser-sync start --server --files='./*.html'" | |
}, | |
"author": "", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 指定サイズ以内の画像幅、高さを算出、 | |
* img要素にそのサイズを適用する | |
* | |
* 使い方: | |
* | |
* 例) 幅150px, 高さ200px以内で画像を表示する | |
* var img = document.createElement('img'); | |
* img.src = 'http://hoge.com/img/fuga.jpg'; | |
* imgResize.resize(img, 150, 200); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get works relational post. | |
* | |
* @return mixed | |
*/ | |
function all_posts_relational_post( $post, $taxonomy, $num, $orderby = 'rand' ) { | |
$post_type = get_post_type( $post ); | |
$post_type_obj = get_post_type_object( $post_type ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function multiple_filter_at_cpt() { | |
global $typenow; | |
$args = array( | |
'public' => true, | |
'_builtin' => true, | |
); | |
$custom_post_types = get_post_types( $args ); | |
$custom_post_types = array_values( $custom_post_types ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( function( $ ) { | |
$( '#acf-image_ba td:nth-child(4) input[type="text"]' ).attr({ | |
'readonly': true, | |
'onclick': 'this.select()', | |
'title': '選択部分をコピー( ctrl + c )して貼り付けたい部分へペーストします。' | |
}); | |
$( '#acf-image_ba .acf-button' ).on( 'click', function( event ) { | |
var target = $( 'td:nth-child(4)' ).find( 'input[type="text"]' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$post_id = 19409; | |
$child_field_count = intval( get_post_meta($post_id, 'supportcase_', true) ); | |
var_dump($child_field_count); | |
for ( $i=0; $i < $child_field_count; $i++ ){ | |
$case = get_post_meta($post_id, sprintf('supportcase__%d__case', $i), true); | |
var_dump($case); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wp', 'only_login_user', 0 ); | |
function only_login_user( $content ) { | |
global $post; | |
$post_type = 'post_type'; | |
$taxonomy = $taxonomy; | |
if( ! is_admin() && ( get_post_type() === $post_type || is_tax( $taxonomy ) ) | |
&& ! is_user_logged_in() ) { |