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 | |
class My_Walker_Page extends Walker_Page { | |
public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) { | |
if ( $depth ) { | |
$indent = str_repeat( "\t", $depth ); | |
} else { | |
$indent = ''; | |
} | |
$css_class = array( 'page_item', 'page-item-' . $page->ID ); |
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 | |
// functions.php に追記 | |
function terms($a, $b){ | |
if ( intval($a->term_order) == intval($b->term_order)) { | |
return 0; | |
} | |
return (intval($a->term_order) < intval($b->term_order)) ? -1 : 1; | |
} |
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 | |
/** | |
* JavascriptとCSSの設定 | |
*/ | |
function my_scripts() { | |
global $post; | |
// テーマ全体で必要なJavascriptとCSS | |
wp_enqueue_style( 'theme-style', get_stylesheet_uri() ); | |
wp_enqueue_script( 'theme-script', get_template_directory_uri() . '/js/script.js', array( 'jquery' ), '', false ); |
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 | |
/** | |
* Custom default column setting for gallery shortcode. | |
* | |
* Original galleryDefaults settings is in wp-includes/js/media-editor.js | |
* Need this setting for admin panel | |
* | |
*/ | |
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 | |
//ループ内で使用 | |
//アイキャッチ画像を$thumbに格納 | |
if( has_post_thumbnail() ) { | |
//アイキャッチ画像が設定されているとき | |
$thumb = get_the_post_thumbnail( $post->ID, 'thumbnail' ); | |
} else { | |
//記事に配置した画像にはwp-image-{id}というクラスが付くのを利用して記事に画像があるかどうか判断 | |
preg_match('/wp-image-(\d+)/i' , $post->post_content, $thumbs); | |
if( empty( $thumbs ) ){ |
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: WordPress Custom Post Type Archive | |
Author URI: http://www.gingerlime.com | |
Description: Displays a monthly or yearly archive of posts for one specific custom post type. | |
Version: 1.0 | |
Requires at least: 3.1 | |
Author: Yoav Aner (based on Wordpress Category Archive by Hugh Mandeville) | |
License: GPL |
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
/* | |
* fixHeight - jQuery Plugin | |
* http://www.starryworks.co.jp/blog/tips/javascript/fixheightjs.html | |
* | |
* Author Koji Kimura @ STARRYWORKS inc. | |
* http://www.starryworks.co.jp/ | |
* | |
* Licensed under the MIT License | |
* | |
*/ |
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 | |
/** | |
* Shortcode to fetch permalink by slug for page, category, post | |
* | |
* [permalink type='cat' slug='hoge'] | |
* | |
* @param type :page(default), cat, post | |
* @param slug :only child page needs parent slug. eg.slug='parent/child' | |
* | |
* @return url string |
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 | |
// [filesize file="filename.pdf"] | |
function get_file_size($atts) { | |
extract(shortcode_atts(array( | |
'file' => '', | |
), $atts)); | |
//pdfの置き場所にあわせてパスを設定 | |
$mfile=WP_CONTENT_DIR."/pdf/".$file; | |
if ( is_file($mfile) ){ |
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 if ( in_category( array('category1','category2','category3')) ): ?> | |
<?php | |
$fields = $cfs->get(false, $post->ID, array('format' => 'raw')); | |
$list = ''; | |
if( $fields ) { | |
$list = '<ul class="post-meta">'; | |
foreach ($fields as $key => $value){ | |
$list .= '<li>'. $key .':'. $value[0] .'</li>'; | |
} | |
$list .= '</ul>'; |
NewerOlder