Skip to content

Instantly share code, notes, and snippets.

@yhira
yhira / noindex.sql
Created August 26, 2018 13:41
Cocoon投稿ページのnoindexが有効になっているIDを取得する
SELECT * FROM `wp_postmeta` WHERE `meta_key` = 'the_page_noindex' AND `meta_value` = '1'
@yhira
yhira / nofollow.sql
Created August 26, 2018 13:38
Cocoon投稿ページでnofollowが有効になっているものを取得
SELECT * FROM `wp_postmeta` WHERE `meta_key` = 'the_page_nofollow' AND `meta_value` = '1'
@yhira
yhira / 楽天商品リンク.js
Last active August 22, 2018 14:50
楽天商品リンクのブックマークレット
javascript:(function(){
var url = location.href;
var host = location.host;
var item_code = null;
var shortcode = null;
var title = null;
if (host == 'item.rakuten.co.jp'){
var metas = document.getElementsByTagName('meta');
for (var i=0; i<metas.length; i++) {
if (metas[i].getAttribute('property') == 'apprakuten:item_code') {
@yhira
yhira / ad-on.sql
Last active August 19, 2018 15:03
Simplicityを利用しているデータベースで広告が有効になっているpost_idを取得
SELECT * FROM`wp_postmeta`WHERE`meta_key`= 'is_ads_removed_in_page' AND`meta_value`= 'on'
@yhira
yhira / get_skin_url.php
Created July 9, 2018 13:12
Cocoonでget_skin_url関数をオーバーライドしてページ毎にスキンを切り替えるコード例
function get_skin_url(){
$skin_file = get_theme_option(OP_SKIN_URL, '');
if (is_single('m-sora')) {
$skin_file = get_template_directory_uri().'/skins/m-sora/style.css';
} elseif (is_single('itsumono-skin')) {
$skin_file = get_template_directory_uri().'/skins/skin-ganchan02/style.css';
} elseif (is_single('odekake')) {
$skin_file = get_template_directory_uri().'/skins/skin-ganchan11/style.css';
} elseif (is_single(array('modernblack', '0-6-2'))) {
$skin_file = get_template_directory_uri().'/skins/skin-modernblack/style.css';
@yhira
yhira / list.php
Created July 3, 2018 14:18
tmp/list.phpのインデックスリストボトムウィジェットとページネーションの順番の入れ替え場所
//以下の部分の順番を入れ替える
<?php
////////////////////////////
//インデックスリストボトムウィジェット
////////////////////////////
if ( is_active_sidebar( 'index-bottom' ) ){
dynamic_sidebar( 'index-bottom' );
}; ?>
<?php
@yhira
yhira / ad_func.php
Created June 30, 2018 14:16
Cocoonの「adsbygoogle.push() error: No slot size for availableWidth=0」エラー対応案
function get_normal_adsense_responsive_code($format = DATA_AD_FORMAT_AUTO, $code = null){
//$codeに広告コードが入っている場合はそこから取得する(無い場合はテーマ設定のAdSenseコードを利用)
if (get_adsense_ids($code)) {
$data_ad_layout = null;
//フォーマットが設定されていない場合はフォーマットをコード内から取得
if ($format == 'none') {
if (preg_match('{data-ad-format="([^"]+?)"}i', $code, $m)) {
if (isset($m[1])) {
@yhira
yhira / H2見出しのタグを除去しないカスタマイズ.php
Created May 27, 2018 09:59
H2見出しのタグを除去しないカスタマイズ
function add_toc_before_1st_h2($the_content){
//投稿ページだと表示しない
if (!is_single_toc_visible() && is_single()) {
return $the_content;
}
//固定ページだと表示しない
if (!is_page_toc_visible() && is_page()) {
return $the_content;
}
@yhira
yhira / 4カラム.html
Created May 22, 2018 13:25
Cocoonテーマで4カラムコード例
<div class="column-wrap column-2">
<div class="column-left">
<div class="column-wrap column-2">
<div class="column-left"> 左側に入力する内容1 </div>
<div class="column-right"> 右側に入力する内容1 </div>
</div>
</div>
<div class="column-right">
<div class="column-wrap column-2">
<div class="column-left"> 右側に入力する内容2 </div>
@yhira
yhira / demo.css
Created April 21, 2018 03:51
CSSサンプル
#london {
background-color: gray;
}
#Batman {
background-color: #000;
opacity: 0.3;
}
#hulk {