This file contains hidden or 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 | |
/* | |
Usage: | |
if ( is_current_page_by_path( '/hoge' ) ) { | |
// is hoge page | |
} else { | |
// is not hoge page | |
} | |
*/ |
This file contains hidden or 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
/** | |
* Usage: if ( is_new() ) : echo 'NEW!'; endif; | |
* you can check if the post was posted within 30 days. | |
*/ | |
function is_new($day=30,$post=null){ | |
$term = $day * 24 * 60 * 60; | |
$post = get_post($post); | |
if ( !$post || is_wp_error( $post ) ) | |
return false; | |
$the_time = $post->post_date; |
This file contains hidden or 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 | |
/* | |
* Usage | |
* if ( is_subpage( get_the_ID() ) : | |
* // subpage | |
* else: | |
* // not a subpage | |
* endif; | |
*/ | |
function is_subpage( $post ) { |
This file contains hidden or 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 | |
/** | |
* Usage | |
* if ( has_children( get_the_ID() ) ) : | |
* // this post has children | |
* else: | |
* // this post has no children | |
* endif; | |
*/ | |
function has_children( $post ) { |
This file contains hidden or 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 getDateStringI18n(string){ | |
var parts = String(string).split(/[- :]/); | |
var newString = parts[0] + '年' + parts[1] + '月' + parts[2] + '日'; | |
return newString; | |
} |
This file contains hidden or 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 | |
/** | |
* Customize Adjacent Post Link Order | |
*/ | |
function my_custom_adjacent_post_where($sql) { | |
if ( !is_main_query() || !is_singular() ) | |
return $sql; | |
$the_post = get_post( get_the_ID() ); | |
$patterns = array(); |
This file contains hidden or 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
// please paste it in your functions.php | |
function filter_facebook_locale($locale){ | |
$wp_locale = get_locale(); | |
if ( $wp_locale = 'ja' ) $locale = 'ja_JP'; | |
return $locale; | |
} | |
add_filter('fb_locale','filter_facebook_locale'); |
This file contains hidden or 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
/** | |
* Custom Post Type Support with CMS Page Order Plugin | |
* http://wordpress.org/extend/plugins/cms-page-order/ | |
*/ | |
function my_filter_cmspageorder($post_types){ | |
$post_types[] = 'custom'; // add 'custom' post type | |
return $post_types; | |
} | |
add_filter('cmspo_post_types','my_filter_cmspageorder'); |
This file contains hidden or 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( 'admin_menu', 'admin_menu_order_hack', 9); // 9 is the priority contact form 7 applies. | |
function admin_menu_order_hack() { | |
global $_wp_last_object_menu; | |
$_wp_last_object_menu++; | |
} |
This file contains hidden or 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 | |
/** | |
* This is a example: force to use index.php at tag archive | |
*/ | |
function my_template_include($template){ | |
if ( is_tag() ) { | |
$template = get_index_template(); | |
} | |
return $template; | |
} |