Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / gist:4323847
Created December 18, 2012 00:39
ループ内のカスタムフィールドの書き方を3.5でもそれ以下でも動くように書こうとしたらたぶんこうなるよね。
$myposts = get_posts($args);
foreach ( $myposts as $post ) :
if ( ! is_a( $post, 'WP_Post' ) ) {
$post->meta_key = get_post_meta( $post->ID, 'meta_key', true );
}
echo $post->meta_key;
@hissy
hissy / gist:4324036
Created December 18, 2012 01:04
WordPress: get permalink by page path
<?php echo get_permalink( get_page_by_path( 'page-slug/children' ) ); ?>
@hissy
hissy / single_page.php
Last active February 4, 2020 23:11
How to use Bootstrap Tabs in concrete5 dashboard
<?php echo Loader::helper('concrete/dashboard')->getDashboardPaneHeaderWrapper(t('Single Page Name'), false, false, false, false, false, false); ?>
<div class="ccm-pane-body">
<?php
// Tab setting using array
$tabs = array(
// array('tab-id', 'Tag Label', true=active)
array('tab-1', 'Tab 1', true),
array('tab-2', 'Tab 2'),
@hissy
hissy / show_morelink_in_single.php
Last active December 10, 2015 11:08
WordPressのシングルページでは通常全文が表示されるが、シングルページでも「続きを読む」リンクを表示し、リンクをクリックすると全文を表示するプラグイン
@hissy
hissy / sharebar.php
Last active December 10, 2015 12:08
make sharebar plugin compatible with 3.5
function sharebar($print = true){
global $wpdb, $post;
$sharebar_hide = get_post_meta($post->ID, 'sharebar_hide', true);
$sbg = get_option('sharebar_sbg');
$sborder = get_option('sharebar_sborder');
if(empty($sharebar_hide)) {
$credit = get_option('sharebar_credit');
$str = '<ul id="sharebar" style="background:#'.$sbg.';border-color:#'.$sborder.';">';
$results = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC"); $str .= "\n";
foreach($results as $result){ $str .= '<li>'.sharebar_filter($result->big).'</li>'; }
@hissy
hissy / enable_post_type_search_template.php
Created January 8, 2013 13:50
simple WordPress plugin that enables use of post type search templates
<?php
/*
Plugin Name: Enable Post Type Search Template
Description: you can use search-{$post_type}.php
Author: Takuro Hishikawa
Version: 0.1
*/
function enable_post_type_search_template($template){
if ( is_search() ) {
@hissy
hissy / gist:4492171
Created January 9, 2013 10:28
小ネタ
function my_terms_reverse_filter($terms){
if(is_main_query()) krsort($terms);
return $terms;
}
add_filter('get_the_terms','my_terms_reverse_filter');
@hissy
hissy / hardcode_theme_switcher.php
Created January 16, 2013 15:29
[WordPress] "/about/" というURLにアクセスした時だけ Twenty Ten に切り替える
<?php
/*
Plugin Name: Hardcode theme switcher
Plugin URI: http://ja.forums.wordpress.org/topic/13483
Author: Takuro Hishikawa
Version: 0.1
*/
function my_theme_switcher($theme){
// yes, it's hardcoded!
@hissy
hissy / gist:4646884
Last active December 11, 2015 19:09
[concrete5] Set <html lang=""> attribute value in multilingual site
<?php defined('C5_EXECUTE') or die("Access Denied.");
Loader::model('section', 'multilingual');
$ms = MultilingualSection::getCurrentSection();
if (is_object($ms)) {
$lang = $ms->getLanguage();
} else {
$lang = LANGUAGE;
}
?>
<!DOCTYPE html>
@hissy
hissy / gist:4647258
Created January 27, 2013 07:39
[concrete5] Hardcoded Search block only search in current language site tree
<?php
Loader::model('section', 'multilingual');
$ms = MultilingualSection::getCurrentSection();
if (is_object($ms)) {
$lang = $ms->getLanguage();
$search = BlockType::getByHandle('search');
$search->controller->title = t('Site Search');
$search->controller->buttonText = t('Search');