親タームで分岐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]

必殺文字画像高さ合わせ

<div class="menu_cate"><img src="img/food_menu/menu_cate-01.png" width="90" height="36" alt="一宮、和食、御膳料理" /></div>
.menu_cate{
	padding-top: 30px;
	padding-bottom: 30px;
	vertical-align: top;
	line-height: 36px;
}

画像の高さにラインハイト
バーティカルトップ

画像カレントjs スプリットも使い まずカレントクラスをつける

<!--画像カレントホバー-->
<!--スプリットURL-->
<script type="text/javascript">
$(function(){
	var url = window.location.pathname;
	var url = url.split("/")[1];
	$('.food_menu li a[href="'+url+'"]').parent().addClass('current');
});
</script>

<!--画像カレントホバー-->
<script type="text/javascript" >
$(function(){

 $(".food_menu li:not(.chill):not(.current)").each(function(){
  var a = $(this);
  var img = a.find("img");
  var src_off = img.attr("src");
  var src_on = src_off.replace(/^(.+)_off(\.[^\.]+)$/,"$1_on$2");

  $("<img />").attr("src",src_on);

  a.bind("mouseenter focus", function(){
		img.attr("src", src_on);
		});

  a.bind("mouseleave blur", function(){
		img.attr("src", src_off);
		});
	});
});

 //current表示
$(function() {
  if ($('.food_menu li').hasClass('current')) {
 $(".food_menu li.current  img").attr("src",$(".food_menu li.current  img").attr("src").replace(/^(.+)_off(\.[^\.]+)$/,"$1_current$2"));
  }
});
</script>

表示順を変える カテゴリ インデックス などのアーカイブ

add_action( 'pre_get_posts', 'foo_modify_query_post_order' );
function foo_modify_query_post_order( $query ) {
  if ( $query->is_tax('genre') && $query->is_main_query() ) {
    $query->set( 'orderby', 'menu_order' );
    $query->set( 'order', 'DESC' );
  }
}

add_action( 'pre_get_posts', 'foo_modify_query_post_order2' );
function foo_modify_query_post_order2( $query ) {
  if ( $query->is_tax('test') && $query->is_main_query() ) {
    $query->set( 'orderby', 'menu_order' );
    $query->set( 'order', 'DESC' );
  }
}

参考http://gatespace.jp/2012/09/10/modify_main_queries/

<?php
/**
 * pre_get_posts を使ってメインクエリーを書き換える
 * http://notnil-creative.com/blog/archives/1996
 */
 
add_action( 'pre_get_posts', 'foo_modify_main_query' ); // pre_get_postsにフック
// フック時に使う関数
function foo_modify_main_query( $query ) {
  if ( is_admin() || ! $query->is_main_query() )
    return;
 
  if ( $query->is_home() ) { // ホーム
    $query->set( 'post_type', array( 'post', 'news' ) ); // 投稿とカスタム投稿タイプ news を含める
    return;
  }
 
  if ( $query->is_month() ) { // 月別アーカイブ
    $query->set( 'posts_per_page', -1 ); // すべて表示
    return;
  }
 
  if ( $query->is_category() ) { // カテゴリーアーカイブ
    $query->set( 'posts_per_page', 10 ); // 10件ずつ表示
    return;
  }
 
}

管理画面まとめ

サムネイル画像リサイズ
regenerate-thumbnails

http://www.memo.d-marking.com/?p=779

TinyMCE Advanced
TypePad emoji for TinyMCE
(シンプルライトボックスと被るので別の
wp-jquery-lightbox
を使う
古いバージョンならOK)

PS Disable Auto Formatting

開発時

Duplicate Post

記事コピー

画像 カレントホバー 特殊 リンク無し ドロップ用 :not重ね掛け

<!--画像カレントホバー-->
<script type="text/javascript" >
$(function(){

 $(".d_navi_main_in li:not(.chill):not(.current)").each(function(){ //ここ大事
  var a = $(this);
  var img = a.find("img");
  var src_off = img.attr("src");
  var src_on = src_off.replace(/^(.+)_off(\.[^\.]+)$/,"$1_on$2");

  $("<img />").attr("src",src_on);

  a.bind("mouseenter focus", function(){
		img.attr("src", src_on);
		});

  a.bind("mouseleave blur", function(){
		img.attr("src", src_off);
		});
	});
});

 //current表示
$(function() {
  if ($('.d_navi_main_in li').hasClass('current')) {
 $(".d_navi_main_in li.current  img").attr("src",$(".d_navi_main_in li.current  img").attr("src").replace(/^(.+)_off(\.[^\.]+)$/,"$1_current$2"));//ここ大事
  }
});
</script>

ドロップダウン 自作

まず普通に 出てる状態を作り
消して
ホバーで見せる
hidden 0がポイント
参考
http://weboook.blog22.fc2.com/blog-entry-359.html

<li class="line"><img src="img/menu/line.png" width="1" height="29" /></li>

<li><img src="img/menu/menu-04_off.jpg" width="127" height="61" />

ここから

<ul class="drop_down">
<li class="chill"><a href="<?php echo home_url(); ?>/?page_id=34">尾張旭店</a></li>
<li class="chill"><a href="<?php echo home_url(); ?>/?page_id=37">日進店</a></li>
</ul>


ここまで

</li>

<li class="line"><img src="img/menu/line.png" width="1" height="29" /></li>
.drop_down{
	z-index: 10000;
	overflow: visible!important;
	position: absolute;
	width: 127px;
}

.drop_down li{
	
	width: 100%;
	background-color: #24AC66;
	
	/*ここで隠し*/
	height: 0px!important;
	overflow:hidden!important;
	/*/ここで隠し*/
}
/*ここでみせる*/
.d_navi_main_in ul li:hover .drop_down li{
	height: auto!important;
	overflow: visible!important;
}
/*/ここでみせる*/



.drop_down li a{
	color: #FFF;
	background-color: #2CB370;
	text-align: center;
	width: 100%;
	display: block;
	padding-top: 10px;
	padding-bottom: 10px;
}

.drop_down li a:hover{
	/*background-color: #ff8e00;*/
	text-decoration: none;
	background-color: #74491C;
}

タブメニュー自作 コード css

マイナスマージンが決め手
オーバーフロー hidenも注意 使わない

<!------------------タブ店舗全ページ----------------------------------> 
<ul class="tab_menu">
<li><a href="<?php echo home_url(); ?>/?page_id=34" class="current">尾張旭店</a></li>
<li><a href="<?php echo home_url(); ?>/?page_id=37">日進店</a></li>
<div style="clear:both"></div>
</ul>

<!------------------/タブ店舗全ページ----------------------------------> 
/*タブ*/

.tab_menu{
	border-bottom-width: 1px;
	border-bottom-style: solid;
	border-bottom-color: #CCC;
	padding-top: 0px;
	padding-right: 0px;
	padding-bottom: 0px;
	padding-left: 10px;
	margin-top: 10px;
	margin-right: 0px;
	margin-bottom: 30px;
	margin-left: 0px;
}
.tab_menu li{
	float: left;
	list-style-type: none;
	margin-bottom: -1px;
	margin-left: -1px;	

}
.tab_menu li a{
	display: block;
	border-top-width: 1px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: solid;
	border-top-color: #CCC;
	border-right-color: #CCC;
	border-bottom-color: #CCC;
	border-left-color: #CCC;
	padding-top: 5px;
	padding-right: 25px;
	padding-bottom: 5px;
	padding-left: 25px;
	-webkit-border-top-left-radius: 5px;
	-webkit-border-top-right-radius: 5px;
	-moz-border-radius-topleft: 5px;
	-moz-border-radius-topright: 5px;
}

.tab_menu li a:hover{
	color: #FFF;
	background-color: #00A550;
	text-decoration: none;
}

.tab_menu li a.current{
	background-color: #6a3906;
	color: #FFF;
	border-bottom-color: #FFF;
}