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_action( 'init', 'create_customeposttype_menu' ); | |
function create_customeposttype_menu() { | |
$label_arr = array( | |
'name' => 'メニュー', | |
'singular_name' => 'メニュー', | |
'search_items' => 'メニューを検索する', | |
// 'parent_item_colon' => '' //非階層タイプでは利用しない | |
); |
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
<? | |
$args = array( | |
'type' => 'string', | |
'home_label' => 'HOME', | |
); | |
if ( function_exists( 'bread_crumb' ) ) { bread_crumb($args); } | |
?> |
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
<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; |
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
<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 ) { |
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 | |
/* | |
Plugin Name: Hoshino Goroku | |
Description: これはただのプラグインではありません。Kunitoshi Hoshino によって発言/ツイートされた最も有名な二つの言葉、「なんとー」、「なるほどですね」 に要約されたWordPressが好きな人々の希望と情熱を象徴するものです。このプラグインが有効にされると、すべての管理画面の右上に <cite>またお会い出来ますことを楽しみにしています</cite> などの言葉がランダムに表示されます。 | |
Author: Friends of @khoshino | |
Version: 0.1 | |
*/ | |
function hossy_words() { | |
$words = "ほほう。 |
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 get_the_khoshino($destination == null, $username == null) { | |
if ( $destination ) { | |
return 'というわけで、' . $destination . 'に向かっています'; | |
} else { | |
if (!empty($username)) { | |
return 'いやいや'.$username.'さんほどでは。'; | |
} else { | |
return 'やはりですか。なるほどですね。'; | |
} |
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 | |
// example.com?what=abc&where=xyz | |
// category | |
$what = $_GET['what']; | |
$okCats = get_categories(); | |
foreach ( $okCats as $oks ) { | |
$okCatsArr[] = $oks->name; | |
} | |
$ifWhat = in_array($what, $okCatsArr); |
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 | |
// category の場合 | |
$what = get_term_by( 'name', $_GET['what'], 'category', 'ARRAY_A' ); | |
// district というタクソノミの場合 | |
$where = get_term_by( 'name', $_GET['where'], 'district', 'ARRAY_A' ); | |
// https://gist.github.com/4139337 これが長い方 |
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 manage_posts_columns($columns) { | |
unset($columns['tags']); | |
unset($columns['comments']); | |
global $post; | |
if ( $post->post_type == 'post' ) { // ポストタイプが投稿の時だけ | |
$date_escape = $columns['date']; // いったん避難 | |
unset($columns['date']); // 消す | |
$columns['district'] = '地区'; | |
$columns['date'] = $date_escape; // ここで戻すと日付が最後になる |
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 | |
// タクソノミ取得 | |
$catargs = array( | |
'taxonomy' => 'specialcat' | |
); | |
$catlists = get_categories( $catargs ); | |
foreach($catlists as $cat) : // 取得したカテゴリの配列でループを回す | |
/* | |
// タクソノミひとつひとつのオブジェクトの中身を見る | |
if ( is_user_logged_in() ) { |
OlderNewer