Skip to content

Instantly share code, notes, and snippets.

@mypacecreator
mypacecreator / relatedlink.php
Created March 10, 2021 01:56
改行、カンマ区切りで入力されたカスタムフィールドの値を分解してループで出力(昔やったやつ)
@mypacecreator
mypacecreator / private-debug-log.php
Created December 20, 2018 02:28 — forked from webaware/private-debug-log.php
Enable WordPress debug log to a private folder not accessible from the web. See http://wordpress.stackexchange.com/q/84132/24260 for details and motivations. NB: currently needs to be manually edited to specify the private folder path;
<?php
/*
Plugin Name: Private Debug Log
Description: Enable debug log to a private folder not accessible from the web
Version: 0.0.1
Author: WebAware
Author URI: http://www.webaware.com.au/
*/
/*
@mypacecreator
mypacecreator / mtk
Last active July 30, 2018 10:36 — forked from ysugimoto/mtk
mtkするやつ
#!/bin/sh
echo '玉子とじラーメン 730円(大盛900円)'
echo '玉子とじ担々麺 850円(大盛1030円)'
echo 'もやし麺 850円(大盛1030円)'
echo 'ワンタン麺 850円(大盛1030円)'
echo '叉焼麺 850円(大盛1030円)'
echo '天津麺 850円(大盛1030円)'
echo '五目麺 850円(大盛1030円)'
echo '替玉 180円'
@mypacecreator
mypacecreator / functions.php
Last active March 27, 2018 08:59
singleページの前後リンクの %link% 部分で、a要素の内側にさらにspanを入れる
<?php
/**
* 前後リンクの出力部分で、a要素の内側にさらにspanを入れる
*
* @param string $link Link permalink format.
*
* @return string
*/
function my_post_link( $link ) {
$link = preg_replace( '/<a href="(.+?)">(.+?)<\/a>/', '<a href="$1"><span>$2</span></a>', $link );
@mypacecreator
mypacecreator / functions.php
Last active March 27, 2018 09:00
wp_list_categories の出力で、カレント表示のclass名の変更と、a要素の内側にさらにspanを入れる
<?php
/**
* wp_list_categories の出力を支給HTMLに合わせて変更
* カレント表示のclass変更、a要素の内側にさらにspanを入れる
*
* @param string $output
*
* @return string
*/
function my_wp_list_categories( $output ) {
@mypacecreator
mypacecreator / custom-fields.php
Last active March 13, 2018 09:32
Smart Custom Fieldsでよくある都道府県のプルダウン項目を作る
<?php //
$Setting->add_group(
'group-pref', false, array(
array(
'name' => 'cf_prefecture',
'label' => '都道府県(テキスト)',
'type' => 'select',
'choices' => array(
'北海道' => '北海道',
'青森県' => '青森県',
@mypacecreator
mypacecreator / .htaccess
Created March 12, 2018 04:39
CPI旧シェアードプランでTLS1.2に対応したPHPを使う
AddHandler x-httpd-php528a .php
Options +SymLinksIfOwnerMatch
@mypacecreator
mypacecreator / refine-search-checkbox.php
Created January 15, 2018 11:47 — forked from yujiokayama/refine-search-checkbox.php
カスタム投稿タイプのカスタムタクソノミー(タグ)をチェックボックスで絞り込み検索
<!--カスタム投稿のタグをチェックボックスで絞り込み-->
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<label for="s" class="assistive-text">検索</label>
<h2>タグまたはカスタムタクソノミー</h2>
<?php
$taxonomy_name = 'cpt_tag';
$taxonomys = get_terms($taxonomy_name);
if(!is_wp_error($taxonomys) && count($taxonomys)):
foreach($taxonomys as $taxonomy):
$tax_posts = get_posts(array('post_type' => get_post_type('cpttype'), 'taxonomy' => $taxonomy_name, 'term' => $taxonomy->slug ) );
@mypacecreator
mypacecreator / archive-faq.php
Last active October 18, 2017 05:39
get_termsとget_postsの入れ子例 改(複数タームに属する記事は2回登場しないように)
<?php
$displayed_post_id = array();
$terms = get_terms(
'faqcategory', array(
'orderby' => 'slug',
'order' => 'ASC'
)
);
foreach( $terms as $term ):
?>
@mypacecreator
mypacecreator / sns.php
Last active October 2, 2017 06:48
シェア系ボタンを自作し、数値はSNS Count Cacheプラグインから出力&自力でHTTP時のいいね数を合算
<?php if( function_exists( 'scc_get_share_facebook' ) ){
$https_count = scc_get_share_facebook();
$http_count = get_post_meta( get_the_ID(), 'scc_http_count_facebook', true );
$total_count = $https_count + $http_count;
} ?>
<div class="social-buttons">
<a href="https://twitter.com/share?url=<?php echo esc_url( get_the_permalink() ); ?>&text=<?php echo urlencode( get_the_title() . ' | ' . get_bloginfo( 'name' ) ); ?>" rel="nofollow" onclick="window.open(this.href, 'tweetwindow', 'width=650, height=470, personalbar=0, toolbar=0, scrollbars=1, sizable=1'); return false;" class="social-btn twitter">
<i class="fa fa-twitter"></i>ツイート
</a>
<a href="https://plus.google.com/share?url=<?php echo esc_url( get_the_permalink() ); ?>" rel="nofollow" class="social-btn gplus">