カスタムフィールドテンプレート 管理画面 デザイン

設定の
オプション
テンプレートフォーマットを選択

[cft] and [cftsearch] Shortcode Format

そのフォーマーットのコードを入れる

保育園テストコード

<div class="cft_admin_title">預かり年齢</div>
<div class="cft_admin_con">[child_old]</div>

<div class="cft_admin_title">エリア選択(絞込検索用)</div>
<div class="cft_admin_con">[eria_city]</div>

<div class="cft_admin_title">住所(※愛知県から番地まで=マップ表示のため)</div>
<div class="cft_admin_con">[adress]</div>
<div class="cft_admin_title" style="margin-top:0px;">建物名(あれば)</div>
<div class="cft_admin_con">[adress2]</div>



<div style="float:left;">
<div class="cft_admin_title">平日保育開始時間</div>
<div class="cft_admin_con">[open_time][open_min]</div>
</div>
<div style="float:left;">
<div class="cft_admin_title">平日保育終了時間</div>
<div class="cft_admin_con">[close_time][close_min]</div>

</div style="float:left;">

<div style="clear:both"></div>

<div style="float:left;">

<div class="cft_admin_title">土曜保育開始時間</div>
<div class="cft_admin_con">[open_time_sat][open_min_sat]</div>
</div>
<div style="float:left;">
<div class="cft_admin_title">平日保育終了時間</div>
<div class="cft_admin_con">[close_time_sat][close_min_sat]</div>

</div style="float:left;">

<div style="clear:both"></div>

カスタムアドミン

.cft_admin_title{
	margin-top: 20px;
}
.cft_admin_con{ padding:10px;}
.cft_admin_con input[type="text"]{ width:100%; max-width:500px;}
.cft_admin_disp{}

管理画面の文字置き換え

http://ja.forums.wordpress.org/topic/10592

add_filter('gettext', 'change_post_to_article');
add_filter('gettext_with_context', 'change_post_to_article');
add_filter('ngettext', 'change_post_to_article');
add_filter('ngettext_with_context', 'change_post_to_article');

function change_post_to_article($translated) {
    $translated = str_ireplace(
        'ダッシュボード',
        'スペシャルダッシュボード',
        $translated
    );
    return $translated;
}

投稿数を制限する(カスタムポストタイプ対応)

function posts_limit() {
	global $userdata, $post_type, $wpdb;
	if ( $post_type === 'ポストタイプ' ) {
		$item_count = $wpdb->get_var( "SELECT count(*) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'ポストタイプ' AND post_author = $userdata->ID" );
		if ( $item_count >= '制限数' ) { wp_die( "エラーメッセージ" ); }
	}
	return;
}
add_action('admin_head-post-new.php', 'posts_limit');

functions.php 未検証

ie8に対する見解

オフィシャルがスクロールjsできなかった。ie8対応と書いてあるから
ワードプレス関連の相性か?不明

対応策
ie8以下のみに読み込ますもの
それ以外に読み込ます物をわける

ie8以下のみに読み込ますもの

<!--[if lt IE 9]> 
<script src="/js/html5shiv-printshiv.min.js"></script>
<script type="text/javascript" src="/js/selectivizr.js"></script>
<script>
//スムーズスクロール
jQuery(function(){
   // #で始まるアンカーをクリックした場合に処理
   jQuery('a[href^=#]').click(function() {
	  // スクロールの速度
	  var speed = 400; // ミリ秒
	  // アンカーの値取得
	  var href= jQuery(this).attr("href");
	  // 移動先を取得
	  var target = jQuery(href == "#" || href == "" ? 'html' : href);
	  // 移動先を数値で取得
	  var position = target.offset().top;
	  // スムーススクロール
	  jQuery('body,html').animate({scrollTop:position}, speed, 'swing');
	  return false;
   });
});
</script>
<style type="text/css">
#go1,#go2,#go3,#go4,#go5,#go6,#go7{
	margin-top: -160px;
	padding-top: 160px;
}
</style>
<![endif]-->

それ以外

<!--[if (gte IE 9)|!(IE)]><!-->
<script type="text/javascript" src="/js/jquery.multirollover.js"></script>

<script>
	$(document).ready(function() {
		$('#head_rogo a').multirollover({
			crossfade	: true,
			suffix		: '_on',
			duration	: 300,

		});
	});
</script>

<script type="text/javascript" src="/js/jquery.page-scroller-309.js"></script>
<!--<![endif]-->

今回は8以下は
スクロールを

<script>
//スムーズスクロール
jQuery(function(){
   // #で始まるアンカーをクリックした場合に処理
   jQuery('a[href^=#]').click(function() {
	  // スクロールの速度
	  var speed = 400; // ミリ秒
	  // アンカーの値取得
	  var href= jQuery(this).attr("href");
	  // 移動先を取得
	  var target = jQuery(href == "#" || href == "" ? 'html' : href);
	  // 移動先を数値で取得
	  var position = target.offset().top;
	  // スムーススクロール
	  jQuery('body,html').animate({scrollTop:position}, speed, 'swing');
	  return false;
   });
});
</script>

で対応し
アンカーをあえて空DIVを入れて
パディングとマイナスマージンで対応

こういう調整は空DIVの有用性ってあるねって思ったし!

結局ie8のセレクタは使用できなかった。

<script src="/js/html5shiv-printshiv.min.js"></script>
<script type="text/javascript" src="/js/selectivizr.js"></script>

こいつをいれる

しかし
デザイン的なcssのずれなどは治った。

どうしても何番目かを指定したい場合は
http://tasudesign.com/web-desing/nth-child/
http://www.gravity-works.jp/gravica/web/003862.html
これで対応してみよう。

サイドバーのまとめ

//サイドバー
register_sidebars(5, array('before_widget' => '<div>',
	'after_widget' => '</div>'));

ファンクションに書く

<?php $args = array(
	'name'          => sprintf(__('Sidebar %d'), $i ),
	'id'            => 'sidebar-$i',
	'description'   => ''
	'before_widget' => '<li id="%1$s" class="widget %2$s">',
	'after_widget'  => '</li>',
	'before_title'  => '<h2 class="widgettitle">',
	'after_title'   => '</h2>' ); ?>

デフォルトが上

抜粋 the_excerpt の[…] を変える


//echo mb_substr(get_the_excerpt(),0, 240);の...を変える
function new_excerpt_more($more) {
	return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');



//抜粋文字数指定 マルチバイトパッチ必要
function change_excerpt_mblength($length) {
return 111;
}
add_filter('excerpt_mblength', 'change_excerpt_mblength');



unction.phpに以下のコードを追加しますと、「続きを読む」などのリンクに変更

function new_excerpt_more($post) {
    return '<a href="'. get_permalink($post->ID) . '">' . '...続きを読む' . '</a>';    
}    
add_filter('excerpt_more', 'new_excerpt_more');


オリジナル
//抜粋カスタマイズ
function new_excerpt_more($post) {
    return '...<div class="blog_more"><a href="'. get_permalink($post->ID) . '">' . '続きを読む▶▶' . '</a></div>';    
}    
add_filter('excerpt_more', 'new_excerpt_more');

自社紹介のみ様をとる

タクソノミー
1.
<?php
echo $term->name; ?><?php if(is_tax('client') and !is_tax('client','d-marking-design')): echo ' 様';  endif; ?>
 制作実績

2.
<?php if(is_tax('client','d-marking-design')):  ?>
<?php elseif(is_tax('client') and !is_tax('client','d-marking-design')):  //ここのandはなくてもよい?>
<div style="margin-top:15px; text-align:center; font-size:15px;"><i class="icon-coffee"></i>
クライアント様のご紹介</div>

<?php else: ?>
<div style="margin-top:15px; text-align:center; font-size:15px;"><i class="icon-coffee"></i>
ご紹介できる制作物の一部をご紹介いたします。</div>
 <?php endif; ?> 


シングル

<div class="jirei_disp_title">クライアント名:</div><div class="jirei_disp_con"><?php echo get_the_term_list($post->ID, 'client'); ?> <?php if(! is_object_in_term($post->ID, 'client','76') ): echo '様'; endif;?></div>

topフラッグ移行時 トランスミット・googleドライブ・MAMPでCGI/Perl

トランスミットでローカルのパーミッション

googleドライブは インストして 名前を変えて バーからエラーをクリック フォルダを探すで再設定

MAMPでCGIは
/Application/MAMP/conf/apache/httpd.conf 453行目ぐらいにある以下の部分を修正する。

#AddHandler cgi-script .cgi
コメントアウト(#)を削除し、.plも動作するように追加する。

AddHandler cgi-script .cgi .pl
編集したhttpd.confを保存してMAMPを再起動してください。

テストCGIの作成とパーミッションの変更
以下のような簡単なCGIを用意してtest.cgiとしてフォルダーに入れました。
test.cgiを保存する際には、必ず改行コードを LF としてください。

#!/usr/bin/perl
print “Content-type: text/html \n\n”;
print “Hello CGI”;

パーミッション
ターミンナル

$ cd /Users/TanakaKimi/Web/
$ chmod 755 test.cgi

トランスミット
右クリック 情報を見るから755

CGI(perl)を /usr/local/bin/perl でも動くようにする

最初に隠しフォルダを表示して
hd user local にbinを作る

Mac OSXのPerl のパスは [/usr/bin/perl] ですが、
一般的なサーバは [/usr/local/bin/perl] だと思います。
そのままだとローカル環境でテストしたCGIを設置サーバにアップするときにPerlのパスを書き換えなければいけません。
そこで [/usr/bin/perl] に加えて [/usr/local/bin/perl] でも動くように設定します。

 

まず [/usr/local/] ディレクトリには [bin] ディレクトリがありませんので、ターミナルで [/usr/local/bin] ディレクトリを作成し、その中にPerlのシンボリックリンク(エイリアス)を作ります。

アプリケーション > ユーティリティ > ターミナルを起動。
以下を入力してください。
※以下のコード部分に含まれる「$」はコマンド入力していることを表していますので、実際には入力しないでください。

$ sudo ln -s /usr/bin/perl /usr/local/bin/perl
これで、MacOS X でも一般的な [/usr/local/bin/perl] で、CGIが動作するようになります。

サクラのCGIは
/usr/bin/perl

777のフォルダの下でも
動くと思っていたけれど、
実は777ではCGIは動かなくて、
705や755にしないと動かない

ファイルパーミッション 755 または 705 のいずれか
ディレクトリパーミッション 755 または 705 のいずれか

 

メモ ポストメールcgi

cgiへ受け渡すhtmlのurlが絶対パスでは

サクラでは駄目だった。

相対パスで受け渡せた。

シングルでターム名を出力 ただし親のカテゴリを選ばずに分類していく場合に 親の名前も取得する

ループ内で
親で分岐と同じコードを使い表示

<h2><div class="title1">
<?php //シングルでターム名を全部取得表示
if ($terms = get_the_terms($post->ID, 'cate_jirei')) {
    foreach ( $terms as $term ) {
        echo esc_html($term->name);
    }
}
?>

<?php  //シングルDDD分岐 $term_p に タームの親のたーむIDが入る 2つのコードで使用

//ループでホームページカテゴリか分岐
//これは親を選択せずに小カテゴリのみ選択していった場合にも有効な親のIDで分岐する方法 但し、複数の親の子は未対応

 //& 親を選択しないカテゴリの場合の親情報を取得 これはすぐしたのコード

//ループ内でタームの親で分岐準備 逆さになる場合があるから下記分岐  
$term = array_pop(get_the_terms($post->ID, 'cate_jirei')); //array_popで配列の最後を取り出す
$term_p = $term->parent; //子か確かめる準備

if ( $term_p == 0 ) //取り出したのが親の場合
{
$term = array_shift(get_the_terms($post->ID,'cate_jirei')); //array_shiftで先頭にある配列を取り出す
}

$term_p = $term->parent; //親のID取得

?>



<?php //ここからシングルのタイトル用のコード

$ddterm = get_term($term_p , 'cate_jirei'); //


echo $ddterm->name;



?>





 実績
</div></h2>

親タームで分岐1

タクソノミー

<?php 
//タクソノミーで親のタームIDで分岐
//カテゴリー・タグ情報を取得(slug,アーカイブページでターム名取得,タクソノミー名取得)
$term = get_term_by('slug',get_query_var( 'term' ),get_query_var( 'taxonomy' )
);
?>
<?php //$termにはいってる情報で分岐
if ( $term->parent ) { // 親IDが入ってれば (子だったら)
?>

<!---TOP部分-->
<?php //親のIDを取得してターム情報を引き出す。
$ido=$term->parent;
}?>




  <?php //タームで分岐デザインフォーマット
  
  if ($ido == 2):
 if (is_object_in_term($post->ID, 'hp_cate','フォーマットデザイン')): ?>
  
  <div class="original original2 ">フォーマット</div>
   <?php else: ?> 
<div class="original">オリジナルデザイン</div>
  <?php endif; ?>
  
    <?php endif; ?>


シングル等ループ内


<?php 
//ループでホームページカテゴリか分岐
//これは親を選択せずに小カテゴリのみ選択していった場合にも有効な親のIDで分岐する方法 但し、複数の親の子は未対応

//ループ内でタームの親で分岐準備 逆さになる場合があるから下記分岐  
$term = array_pop(get_the_terms($post->ID, 'cate_jirei')); //array_popで配列の最後を取り出す
$term_p = $term->parent; //子か確かめる準備

if ( $term_p == 0 ) //取り出したのが親の場合
{
$term = array_shift(get_the_terms($post->ID,'cate_jirei')); //array_shiftで先頭にある配列を取り出す
}

$term_p = $term->parent; //親のID取得

if($term_p == 2):

?>

  <?php //タームで分岐デザインフォーマット
 if (is_object_in_term($post->ID, 'hp_cate','フォーマットデザイン')): ?>
  
  <div class="original original2 d_original">フォーマット</div>
   <?php else: ?> 
<div class="original d_original">オリジナルデザイン</div>
  <?php endif; ?>
    <?php endif; 
	//ホームページ分岐終わり?>

上記ベースコード

http://liginc.co.jp/designer/archives/4348

親カテゴリ 分岐 

※なんかうまくいかなかった

ファンクションへ
タクソノミーだけなら下の部分だけでOK

/* For categories */
if ( ! function_exists( 'post_is_in_descendant_category' ) ) :
function post_is_in_descendant_category( $cats, $_post = null ) {
  foreach ( (array) $cats as $cat ) {
		// get_term_children() accepts integer ID only
		$descendants = get_term_children( (int) $cat, 'category' );
		if ( $descendants && in_category( $descendants, $_post ) )
			return true;
	}
	return false;
}
function post_is_in_category_slug($slug){
	global $post;
	$post_id = ( isset($post->ID) ) ? $post->ID : '';
	if ( in_category( $slug, $post_id ) || post_is_in_descendant_category( get_term_by('slug',$slug,'category'), $post_id ) ){
		return true;
	} else {
		return false;
	}
}
endif; //function_exists 'post_is_in_descendant_category'
 
 
/* For taxonomies */
if ( ! function_exists( 'post_is_in_descendant_taxonomy' ) ) :
function post_is_in_descendant_taxonomy( $terms, $taxonomy, $_post = null ) {
	foreach ( (array) $terms as $term ) {
		// get_term_children() accepts integer ID only
		$descendants = get_term_children( (int) $term, $taxonomy );
		if ( $descendants && has_term( $descendants, $taxonomy, $_post ) )
			return true;
	}
	return false;
}
function post_is_in_taxonomy_slug($slug, $taxonomy){
	global $post;
	$post_id = ( isset($post->ID) ) ? $post->ID : '';
	if ( has_term( $slug, $taxonomy, $post_id ) || post_is_in_descendant_taxonomy( get_term_by('slug',$slug,$taxonomy), $taxonomy, $post_id ) ){
		return true;
	} else {
		return false;
	}
}
endif; //function_exists 'post_is_in_descendant_taxonomy'
//宅
if ( post_is_in_taxonomy_slug('Cat-A', カスタムタクソノミー名) )
//具体例
<?php
  if (post_is_in_taxonomy_slug('ホームページ制作', cate_jirei) ):
?>
<?php endif; ?>

//カテ

if ( post_is_in_category_slug('Cat-A')

Custom Field Suite で フルのurl付 これは回りくどいか?

 <!--シンプルライトボックス用rel-->
<a rel="slb slb_group[111111]" href="
<?php //イメージFULL URLを取得
$d_url = wp_get_attachment_image_src(get_post_meta($post->ID,"jirei_gazou",true),full);
echo $d_url[0];
?>
">
<?php
$title= get_the_title();
echo wp_get_attachment_image(get_post_meta($post->ID,"jirei_gazou",true),array(330,500),array('alt'=>$title,'title'=>$title)); ?>

</a>

タームで分岐

  <?php if (is_object_in_term($post->ID, 'rental_set','郵送レンタル')): ?>
   <?php else: ?> 
<img src="img/3free.png" alt="音響スタッフ付き/機材運搬100kmまで無料/機材設置料無料" width="373" height="22">
  <?php endif; ?> 

春日井ナビ リフォーム時覚え

・協賛はsimple タクソノミー

・アドミンマイズでダッシュボード権限を投稿者になくし
リダイレクト指示部分で別に飛ばす。

・ロールエディタは 他人の記事を見れなくする。
チェックを外す部分は other delete とother edits

・その他 他人の記事を見れなくすると書いてあったファンクション様コードが2つあった。

http://qiita.com/halhide/items/8c85d4ea8f8584721aeb

//ロールしてるから効果わからんが自分だけポスト
function filter_other_post( $wp_query ) {
    global $pagenow, $current_user;

    if($pagenow != 'admin-ajax.php' && $pagenow != "edit.php" ) {
        return;
    }

    if($current_user->roles[0] == "administrator") {
        //管理者はすべて閲覧可能
        return;
    }

    $wp_query->query_vars['author'] = $current_user->ID;
}

もう一個はみつけられず。

ロールでバグってて、
春日井の食でクーポン有りの投稿だけ他のユーザーから削除までできる感じになっていて、
クーポンあり という新しいカテゴリを作り コードも入換え すべて記事をアサインしなおした。
一応治ったっぽい。

ファンクション分岐

 if (current_user_can('level_10')) {
//ここに投稿一覧に順位を書いた

}


さらに発見

 if (!current_user_can('level_10')) {
//ここに投稿一覧に順位を書いた

}
こう書くと逆に管理者が見えなくなる

・記事一覧カラムの表示をシンプル化した。
そのためアドミンcssに強制ディスプレイnoneで消した。

・カスタムフィールドってやつを消したかったから
カスタムフィールドテンプレートのグローバル設定
「編集リストページのカスタムフィールドカラムの表示を禁止する場合:
カスタムフィールドカラムを無効にする(クイック編集も動きません)」

をチェックした

・タイトルを入力の文字替え

//タイトルを入力してくださいを変える
function change_default_title( $title ) {
	$screen = get_current_screen();
	if ( 'shoku'or'asobu'or'share'or'seikatsu'or'iryou'or'manabu'or'koukyou'or'ofuroyado' == $screen->post_type ) {
		$title = '店舗名を入力';
	} else if ( $screen -> post_type == 'post' ) {
		$title = 'これは投稿を変更します';
	}

	return $title;
}
add_filter('enter_title_here', 'change_default_title');

★カスタムフィールドテンプレートで
改造方法

・アドミンcssでフロート クリアボス
これはカスタムアドミンにかいてもよし
・グローバルセッティングで
初期化・保存ボタンを消す
テンプレートタイトルをボックス名へ

IE9のmargin:auto が効かない

<meta http-equiv="X-UA-Compatible" content="IE=9">

こいつを

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="X-UA-Compatible" content="IE=9">

sakura wwwありなし

①www有り
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^yyy\.com
  RewriteRule (.*) http://www.yyy.com/$1 [R=301,L]
  (最後は空白行)

  ②www無し
  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^www\.yyy\.com
  RewriteRule (.*) http://yyy.com/$1 [R=301,L]
  (最後は空白行)

  ③index有り
  RewriteEngine on
  RewriteRule ^$ /index.html [R=301]
  (最後は空白行)

  ④index無し
  RewriteEngine on
  RewriteCond %{THE_REQUEST} ^.*/index.html
  RewriteRule ^(.*)index.html$ /$1 [R=301,L]
  (最後は空白行)

初期ドメインリダイレクト
Redirect /zback1/sugaryawd/ “http://sugaryawd.com/”

ダブルパンチ例
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.2youngc\.com
RewriteRule (.*) http://2youngc.com/$1 [R=301,L]

RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ /$1 [R=301,L]

ダブルパンチ例

トリプルパンチ
Redirect /zback1/sugaryawd/ “http://sugaryawd.com/”

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.sugaryawd\.com
RewriteRule (.*) http://sugaryawd.com/$1 [R=301,L]

RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ /$1 [R=301,L]

index.php含み
Redirect /zback2/mirto/ “http://http://www.mirto.jp/”

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mirto\.jp
RewriteRule (.*) http://www.mirto.jp/$1 [R=301,L]

RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/index.(html|php)
RewriteRule ^(.*)index.(html|php)$ /$1 [R=301,L]