Skip to content

Instantly share code, notes, and snippets.

add_meta_box('ctameta_box', 'CTA設定', 'bzb_post_cta', 'page', 'normal', 'low');
<?php if(is_category('category1')){ ?>
/* category1専用のCSSファイルを読み込み */
<link rel="stylesheet" type="text/css" href="/css/css1.css">
<?php }elseif('category2'){ ?>
/* category2専用のCSSファイルを読み込み */
<link rel="stylesheet" type="text/css" href="/css/css2.css">
<?php if(is_category($category)){ ?>
/* ここに特定のカテゴリーページでの処理を記述する */
<?php } ?>
<?php
$original = 'XXXXXYYYYYZZZZZ';
$customize = ''
/* 全文削除 */
echo substr_replace($original, $customize, 0) . "<br />\n";
/* 「YYYYY」を削除 */
echo substr_replace($original, $customize, 5, 5) . "<br />\n";
<?php
$original = 'XXXXX/ZZZZZ';
$customize = 'YYYYY'
/* 文字列の「ZZZZZ」を「YYYYY」に置換*/
echo substr_replace($original, $customize, 6) . "<br />\n";
echo substr_replace($original, $customize, 6, 5) . "<br />\n";
echo substr_replace($original, $customize, -5) . "<br />\n";
echo substr_replace($original, $customize, -5, 5) . "<br />\n";
<?php
$original = 'XXXXX';
$customize = 'YYYYY'
/* 文字列の先頭に挿入「YYYYYXXXXX」 */
echo substr_replace($original, $customize, 0, 0) . "<br />\n";
/* 文字列の3文字目から挿入「XXYYYYYXXX」 */
echo substr_replace($original, $customize, 2, 0) . "<br />\n";
substr_replace ( $string , $replacement , $start [, $length ] )
<?php
$original = 'XXXXX';
$customize = 'YYYYY'
/* 文字列「XXXXX」を「YYYYY」に置換 */
echo substr_replace($original, $customize, 0) . "<br />\n";
echo substr_replace($original, $customize, 0, strlen($original)) . "<br />\n";
?>
function add_bzb_meta_tags() {
add_meta_box('bzb_meta_tags', 'メタタグを設定', 'bzb_meta_tags', 'post', 'normal', 'high');
add_meta_box('bzb_meta_tags', 'メタタグを設定', 'bzb_meta_tags', 'voice', 'normal', 'high');
}
<!-- 省略 -->
add_meta_box('bzb_meta_tags', 'メタタグを設定', 'bzb_meta_tags', 'カスタム投稿タイプ名', 'normal', 'high');
<!-- 省略 -->