Skip to content

Instantly share code, notes, and snippets.

View ShinichiNishikawa's full-sized avatar
🏠
Working from home

Shinichi Nishikawa ShinichiNishikawa

🏠
Working from home
View GitHub Profile
@ShinichiNishikawa
ShinichiNishikawa / gist:4108737
Created November 19, 2012 03:08 — forked from gatespace/gist:4108710
最強のテンプレートタグ get_the_khoshino()
<?php
function get_the_khoshino($destination == null, $username == null) {
if ( $destination ) {
return 'というわけで、' . $destination . 'に向かっています';
} else {
if (!empty($username)) {
return 'いやいや'.$username.'さんほどでは。';
} else {
return 'やはりですか。なるほどですね。';
}
@ShinichiNishikawa
ShinichiNishikawa / hoshino-goroku.php
Created March 30, 2012 15:23
hoshino-goroku.php
<?php
/*
Plugin Name: Hoshino Goroku
Description: これはただのプラグインではありません。Kunitoshi Hoshino によって発言/ツイートされた最も有名な二つの言葉、「なんとー」、「なるほどですね」 に要約されたWordPressが好きな人々の希望と情熱を象徴するものです。このプラグインが有効にされると、すべての管理画面の右上に <cite>またお会い出来ますことを楽しみにしています</cite> などの言葉がランダムに表示されます。
Author: Friends of @khoshino
Version: 0.1
*/
function hossy_words() {
$words = "ほほう。
@ShinichiNishikawa
ShinichiNishikawa / get_custom_taxonomy_list.php
Created March 22, 2012 20:10
特定のカスタム投稿タイプの記事の一覧を取得する
<ul>
<?php
$args = array(
'post_type' => 'my_posttype',
'taxonomy' => 'my_taxonomy',
'term' => 'my_term',
'numberposts' => '-1',
);
$my_posts = get_posts($args);
foreach ( $my_posts as $post ) {
@ShinichiNishikawa
ShinichiNishikawa / wp_list_custompost_posts.php
Last active October 2, 2015 03:28
カスタム投稿タイプの投稿一覧で現在表示にcurrentを持たせる
<ul>
<?php
$current_page_id = $wp_query->get_queried_object_id();
$args = array(
'post_type' => 'yourcustomposttype',
);
$your_posts = get_posts($args);
foreach ( $your_posts as $post ) {
setup_postdata($post);
$current_class = null;
@ShinichiNishikawa
ShinichiNishikawa / parameters.php
Created March 22, 2012 07:37
Prime Strategy Bread Crumb
<?
$args = array(
'type' => 'string',
'home_label' => 'HOME',
);
if ( function_exists( 'bread_crumb' ) ) { bread_crumb($args); }
?>
@ShinichiNishikawa
ShinichiNishikawa / functions.php
Created March 12, 2012 17:17
カスタム投稿タイプmenuを登録して、カスタムタクソノミgohantypeを紐付けるfunctions.php
<?php
add_action( 'init', 'create_customeposttype_menu' );
function create_customeposttype_menu() {
$label_arr = array(
'name' => 'メニュー',
'singular_name' => 'メニュー',
'search_items' => 'メニューを検索する',
// 'parent_item_colon' => '' //非階層タイプでは利用しない
);