参考
http://yahss.net/wordpress/260-260/
こいつはカテゴリでかつポストタイプは指定無しのコードだった。
一応記録
<?php
$area = $_GET['area'];//urlにpostが渡されていればそれを取得(urlの例 → http://ドメイン/カテゴリスラグ/?area=新宿区)
$catSlg = $category_name;//カテゴリスラグを取得
$cfKey = 'area';//カスタムフィールドのキー名
//続くリストタグで、絞り込み用のリンクを生成。
//これを応用して、チェックボックスなどにして、複数のカスタムフィールドの値による絞り込みも可能。
?>
<ul>
<li><a href="<?php echo get_option('home'); ?>/<?php echo $catSlg ?>"><?php echo ($area == '')? "<strong>すべて</strong>":"すべて" ?></a></li>
<li><a href="<?php echo get_option('home'); ?>/<?php echo $catSlg ?>/?area=新宿区"><?php echo ($area == '新宿区')? "<strong>新宿区</strong>":"新宿区" ?></a></li>
<li><a href="<?php echo get_option('home'); ?>/<?php echo $catSlg ?>/?area=江東区"><?php echo ($area == '江東区')? "<strong>江東区</strong>":"江東区" ?></a></li>
<li><a href="<?php echo get_option('home'); ?>/<?php echo $catSlg ?>/?area=中央区"><?php echo ($area == '中央区')? "<strong>中央区</strong>":"中央区" ?></a></li>
</ul>
<?php
$args = array(
'category_name' => $catSlg,//カテゴリスラグによる絞り込み
'meta_query' => array(//カスタムフィールドによる絞り込み
array(
'key' => $cfKey,//カスタムフィールド名
'value' => $area,//カスタムフィールドの値
"compare" => "LIKE"
)
),
'posts_per_page' => 10,//1ページあたりの表示件数
'paged' => $paged
);
query_posts($args);//実行
?>
要点すぎてちょっと最初よくわからなかったが、
簡単にいうと 絞り込みボタンに?名前=値 をもたして
URLからその値を取得して
それをクエリポストで入れて表示させる。
つまり、タクソノミーページとかなんだけど
クエリポストを書くってこと。
$area = $_GET['area'];//urlにpostが渡されていればそれを取得(urlの例 → http://ドメイン/カテゴリスラグ/?area=新宿区)
ここで値がなかった場合に普通の絞り込んでないやつがでないから
分岐させた。
クエリポストを発動するURLはつまり?名前=値場合のみってコード
忘れずにリセットクエリも分岐でかいとこう
<?php
$shashu = $_GET['shashu'];//urlにpostが渡されていればそれを取得(urlの例 → http://ドメイン/カテゴリスラグ/?area=新宿区)
if($shashu){//入っていればクエリポスト投げる
$cfKey = 'shashu';//カスタムフィールドのキー名
$args = array(
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => get_query_var( 'taxonomy' ),
'field' => 'slug',
'terms' => get_query_var( 'term' ),
),),
'meta_query' => array(//カスタムフィールドによる絞り込み
array(
'key' => 'shashu',//カスタムフィールド名
'value' => $shashu,//$area,//カスタムフィールドの値
/* "compare" => "LIKE"*/
)
),
// 'posts_per_page' => 10,//1ページあたりの表示件数
'paged' => $paged,
'post_type' => 'shop',
);
query_posts($args);
}
?>
いろんなカテゴリでつかえるように動的にした。
'taxonomy' => get_query_var( 'taxonomy' ), 'field' => 'slug', 'terms' => get_query_var( 'term' ), このあたりとか
ポストタイプと
メタキーは直入れだもんで
他のポストタイプのときは使えんで分岐してかきなおしゃあ
絞り込みボタン
サブカテゴリ(対応車種): <a href="<?php echo get_term_link($term,get_query_var( 'taxonomy')); ?>/?shashu=NA"><span class="na_c icon_sb">NA</span></a><a href="<?php echo get_term_link($term,get_query_var( 'taxonomy')); ?>/?shashu=NB"><span class="nb_c icon_sb ">NB</span></a><a href="<?php echo get_term_link($term,get_query_var( 'taxonomy')); ?>/?shashu=NC"><span class="nc_c icon_sb">NC</span ></a> </div>
<?php echo get_term_link($term,get_query_var( 'taxonomy')); ?>
こいつのあとに
<?php //カテゴリー・タグ情報を取得(slug,アーカイブページでターム名取得,タクソノミー名取得)
$term = get_term_by('slug',get_query_var( 'term' ),get_query_var( 'taxonomy' )
);
?>
ってのがあるけど下記がアッタから注意
カスタムタクソノミーのアーカイブページで、そのページのタクソノミーのスラッグ名を取得する
$term
これだけです。
echo $term;
とすると、タクソノミーのスラッグ名が表示されます。
さらに「get_term_by」を使用すると、そのタクソノミーの情報を取得できます。
$the_term = get_term_by("slug", $term, "タクソノミー名");
うかつに、$termに変数を代入してしまわないよう注意しましょう。
ほかにも、
投稿記事ページで記事の情報を取得できる「$post」
カテゴリーアーカイブページでカテゴリーIDを取得できる「$cat」などがあります。
レスポンシブ DIVスライダーを左コンテンツフロート部分の場合と開いた瞬間から高さを維持するBOX
.viewer {
min-height:447px;
}
<div id="main_contents_top_fade">
<!--
class="d_ab_right"
-->
<div class="viewer">
<ul>
<li>
<img src="/img/top1.jpg" width="100%" alt="エクステリア工事<?php include("d_a_word/d_a_5_shop_name.php") ?>|スライド画像1" />
</li>
<li>
<img src="/img/top1.jpg" width="100%" alt="エクステリア工事<?php include("d_a_word/d_a_5_shop_name.php") ?>|スライド画像1" />
</li>
</ul>
</div>
</div>
$(window).load(function(){}
は表示速度がおそくなるからとった方がいいね
<script>
$(function(){
$(window).load(function(){
var setElm = $('.viewer'),
setMaxWidth = 1200,
setSliderWidth = 840,//+
setMinWidth = 10,
fadeSpeed = 1500,
switchDelay = 5000,
sideNavi = 'off', // 'on' or 'off'
sideHide = 'show', // 'hide' or 'show'
naviOpc = 0.5;
var setElm2 = $('#main_contents_top_fade');//+
setElm.each(function(){
var targetObj = $(this),
findUl = targetObj.find('ul'),
findLi = targetObj.find('li'),
findLiFirst = targetObj.find('li:first');
findLi.css({display:'block',opacity:'0',zIndex:'99'});
findLiFirst.css({zIndex:'100'}).stop().animate({opacity:'1'},fadeSpeed);
function timer(){
setTimer = setInterval(function(){
slideNext();
},switchDelay);
}
timer();
function slideNext(){
findUl.find('li:first-child').not(':animated').animate({opacity:'0'},fadeSpeed).next('li').css({zIndex:'100'}).animate({opacity:'1'},fadeSpeed).end().appendTo(findUl).css({zIndex:'99'});
}
function slidePrev(){
findUl.find('li:first-child').not(':animated').css({zIndex:'99'}).animate({opacity:'0'},fadeSpeed).siblings('li:last-child').css({zIndex:'100'}).animate({opacity:'1'},fadeSpeed).prependTo(findUl);
}
targetObj.css({width:setSliderWidth,display:'block'});//スライダー幅
// メイン画像をベースにエリアの幅と高さを設定
var setLiImg = findLi.find('img'),
baseWidth = setLiImg.width(),
baseHeight = setLiImg.height();
// レスポンシブ動作メイン
function imgSize(){
var windowWidth = parseInt($(window).width());
if(windowWidth >= setMaxWidth) {
targetObj.css({width:setMaxWidth,height:baseHeight});
findUl.css({width:baseWidth,height:baseHeight});
findLi.css({width:baseWidth,height:baseHeight});
setElm2.css({width:baseWidth,height:baseHeight});//+
} else if(windowWidth < setMaxWidth) {
if(windowWidth >= setMinWidth) {
targetObj.css({width:'100%'});
findUl.css({width:'100%'});
findLi.css({width:'100%'});
setElm2.css({width:'100%'}); //+
} else if(windowWidth < setMinWidth) {
targetObj.css({width:setMinWidth});
findUl.css({width:setMinWidth});
findLi.css({width:setMinWidth});
setElm2.css({width:setMinWidth}); //+
}
var reHeight = setLiImg.height();
targetObj.css({height:reHeight});
findUl.css({height:reHeight});
findLi.css({height:reHeight});
setElm2.css({height:reHeight}); //+
}
}
$(window).resize(function(){imgSize();}).resize();
// サイドナビボタン(有り無し)
var agent = navigator.userAgent;
if(sideNavi == 'on'){
targetObj.append('<a href="javascript:void(0);" class="btnPrev"></a><a href="javascript:void(0);" class="btnNext"></a>');
var btnPrev = targetObj.find('.btnPrev'),btnNext = targetObj.find('.btnNext'),btnPrevNext = targetObj.find('.btnPrev,.btnNext');
if(agent.search(/iPhone/) != -1 || agent.search(/iPad/) != -1 || agent.search(/iPod/) != -1 || agent.search(/Android/) != -1){
btnPrevNext.css({opacity:naviOpc});
} else {
btnPrevNext.css({opacity:naviOpc}).hover(function(){
$(this).stop().animate({opacity:naviOpc+0.2},200);
},function(){
$(this).stop().animate({opacity:naviOpc},200);
});
}
if(sideHide == 'hide'){
if(agent.search(/iPhone/) != -1 || agent.search(/iPad/) != -1 || agent.search(/iPod/) != -1 || agent.search(/Android/) != -1){
btnPrevNext.css({visibility:'visible'});
} else {
btnPrevNext.css({visibility:'hidden'});
targetObj.hover(function(){
btnPrevNext.css({visibility:'visible'});
},function(){
btnPrevNext.css({visibility:'hidden'});
});
}
}
btnPrev.click(function(){switchPrev();});
btnNext.click(function(){switchNext();});
}
// ボタン移動動作
function switchNext(){
findLi.not(':animated').parents('ul').each(function(){
clearInterval(setTimer);
slideNext();
timer();
});
}
function switchPrev(){
findLi.not(':animated').parents('ul').each(function(){
clearInterval(setTimer);
slidePrev();
timer();
});
}
});
});
});
</script>
レスポンシブ DIVスライダー
http://black-flag.net/jquery/20131217-4909.html
<div class="viewer"> <ul> <li><a href="#1"><img src="img/photo1.jpg" alt=""></a></li> <li><a href="#2"><img src="img/photo2.jpg" alt=""></a></li> <li><a href="#3"><img src="img/photo3.jpg" alt=""></a></li> <li><a href="#4"><img src="img/photo4.jpg" alt=""></a></li> <li><a href="#5"><img src="img/photo5.jpg" alt=""></a></li> <li><a href="#6"><img src="img/photo6.jpg" alt=""></a></li> </ul> </div><!--/.viewer-->
◆CSS
/* .viewer
------------------------- */
.viewer {
margin: 0 auto;
width: 100%;
position: relative;
overflow: hidden;
}
.viewer ul {
width: 100%;
overflow: hidden;
position: relative;
}
.viewer ul li {
top: 0;
left: 0;
width: 100%;
position: absolute;
}
.viewer ul li img {
width: 100%;
}
/* sideNavi
------------------------- */
.viewer .btnPrev,
.viewer .btnNext {
margin-top: -25px;
top: 50%;
width: 50px;
height: 50px;
position: absolute;
z-index: 101;
}
.viewer .btnPrev {
left: 10px;
background: #ccc url(../img/btnPrev.jpg) no-repeat center center;
}
.viewer .btnNext {
right: 10px;
background: #ccc url(../img/btnNext.jpg) no-repeat center center;
}
/* =======================================
ClearFixElements
======================================= */
.viewer ul:after {
content: ".";
height: 0;
clear: both;
display: block;
visibility: hidden;
}
.viewer ul {
display: inline-block;
overflow: hidden;
}
$(window).load(function(){}
は表示速度がおそくなるからとった方がいいね
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(function(){
$(window).load(function(){
var setElm = $('.viewer'),
setMaxWidth = 800,
setMinWidth = 320,
fadeSpeed = 1500,
switchDelay = 5000,
sideNavi = 'off', // 'on' or 'off'
sideHide = 'hide', // 'hide' or 'show'
naviOpc = 0.5;
setElm.each(function(){
var targetObj = $(this),
findUl = targetObj.find('ul'),
findLi = targetObj.find('li'),
findLiFirst = targetObj.find('li:first');
findLi.css({display:'block',opacity:'0',zIndex:'99'});
findLiFirst.css({zIndex:'100'}).stop().animate({opacity:'1'},fadeSpeed);
function timer(){
setTimer = setInterval(function(){
slideNext();
},switchDelay);
}
timer();
function slideNext(){
findUl.find('li:first-child').not(':animated').animate({opacity:'0'},fadeSpeed).next('li').css({zIndex:'100'}).animate({opacity:'1'},fadeSpeed).end().appendTo(findUl).css({zIndex:'99'});
}
function slidePrev(){
findUl.find('li:first-child').not(':animated').css({zIndex:'99'}).animate({opacity:'0'},fadeSpeed).siblings('li:last-child').css({zIndex:'100'}).animate({opacity:'1'},fadeSpeed).prependTo(findUl);
}
targetObj.css({width:setMaxWidth,display:'block'});
// メイン画像をベースにエリアの幅と高さを設定
var setLiImg = findLi.find('img'),
baseWidth = setLiImg.width(),
baseHeight = setLiImg.height();
// レスポンシブ動作メイン
function imgSize(){
var windowWidth = parseInt($(window).width());
if(windowWidth >= setMaxWidth) {
targetObj.css({width:setMaxWidth,height:baseHeight});
findUl.css({width:baseWidth,height:baseHeight});
findLi.css({width:baseWidth,height:baseHeight});
} else if(windowWidth < setMaxWidth) {
if(windowWidth >= setMinWidth) {
targetObj.css({width:'100%'});
findUl.css({width:'100%'});
findLi.css({width:'100%'});
} else if(windowWidth < setMinWidth) {
targetObj.css({width:setMinWidth});
findUl.css({width:setMinWidth});
findLi.css({width:setMinWidth});
}
var reHeight = setLiImg.height();
targetObj.css({height:reHeight});
findUl.css({height:reHeight});
findLi.css({height:reHeight});
}
}
$(window).resize(function(){imgSize();}).resize();
// サイドナビボタン(有り無し)
var agent = navigator.userAgent;
if(sideNavi == 'on'){
targetObj.append('<a href="javascript:void(0);" class="btnPrev"></a><a href="javascript:void(0);" class="btnNext"></a>');
var btnPrev = targetObj.find('.btnPrev'),btnNext = targetObj.find('.btnNext'),btnPrevNext = targetObj.find('.btnPrev,.btnNext');
if(agent.search(/iPhone/) != -1 || agent.search(/iPad/) != -1 || agent.search(/iPod/) != -1 || agent.search(/Android/) != -1){
btnPrevNext.css({opacity:naviOpc});
} else {
btnPrevNext.css({opacity:naviOpc}).hover(function(){
$(this).stop().animate({opacity:naviOpc+0.2},200);
},function(){
$(this).stop().animate({opacity:naviOpc},200);
});
}
if(sideHide == 'hide'){
if(agent.search(/iPhone/) != -1 || agent.search(/iPad/) != -1 || agent.search(/iPod/) != -1 || agent.search(/Android/) != -1){
btnPrevNext.css({visibility:'visible'});
} else {
btnPrevNext.css({visibility:'hidden'});
targetObj.hover(function(){
btnPrevNext.css({visibility:'visible'});
},function(){
btnPrevNext.css({visibility:'hidden'});
});
}
}
btnPrev.click(function(){switchPrev();});
btnNext.click(function(){switchNext();});
}
// ボタン移動動作
function switchNext(){
findLi.not(':animated').parents('ul').each(function(){
clearInterval(setTimer);
slideNext();
timer();
});
}
function switchPrev(){
findLi.not(':animated').parents('ul').each(function(){
clearInterval(setTimer);
slidePrev();
timer();
});
}
});
});
});
</script>
スクリプト開始部分にある設定値の内容は以下の様になっています。
| var setElm = $(‘.viewer’) | スライドショー全体を囲うブロック要素名(IDでも可) |
|---|---|
| setMaxWidth = 800 | スライドショー部分の最大幅 |
| setMinWidth = 320 | スライドショー部分の最小幅 |
| fadeSpeed = 1500 | フェードアニメーションスピード |
| switchDelay = 5000 | スライドアニメーション待機時間 |
| sideNavi = ‘off’ | 左右NEXT/BACKの表示/非表示(表示する場合は「on」) |
| sideHide = ‘hide’ | 左右NEXT/BACKのロールオーバーで表示切り替えON/OFF(常に表示させる場合は「show」等) |
| naviOpc = 0.5 | 左右NEXT/BACKの透過度 |
これらの設定値を変更することでもろもろ調整が可能になっています。
スクリプト全体はあまりシンプルと言える構成ではありませんが
少しの設定値を調整するだけで簡単に設置することは可能になっているかと思います。
画像サイズ(比率)によって各エリアの幅と高さを取得して制御していることもあり
使用する(切り替える)画像は全て幅と高さを同サイズのものを使用する必要があります。
オプション機能としてスライドショーの左右にNEXT/BACKのボタンを表示させるようにもしてあり、
「sideNavi」を「’on’」や「’off’」とすることで表示/非表示を切り替えることができます。
(記述は「off」でなくても「on」じゃなければ何でもいいです・・・)
表示したNEXT/BACKボタンをスライドショーエリアにカーソルが乗った時のみ
表示させるようにするには「sideHide」を「’hide’」とします。
常にボタンを表示させるにはここの値は「’show’」とします。
(記述は「show」でなくても「hide」じゃなければ何でもいいです・・・)
スライドショー自体は1ページ内に複数設置することも可能になっていますが
複数設置した際にNEXT/BACKボタンをつけるとどうも動作がうまくいかなくなるようなので
複数設置する場合はNEXT/BACKボタンは「off」にしてください。
※不完全ですみません。。
yarpp でカスタム投稿
新規
<?php
yarpp_related(array(
'post_type' => array('shop', 'mycustompost'),
'show_pass_post' => false, // show password-protected posts
'past_only' => false,
'weight' => array(
'body' => 2,
'title' =>2,
'tax' => array(
'shop_cat' => 2,
))
// 'order' => 'score DESC'//載せる順番
// show only posts which were published before the reference post
// 任意のテンプレートを利用する場合指定
//'template' => 'yarpp-template-xxxxxx.php', // either the name of a file in your active theme or the boolean false to use the builtin template
));
?>
https://wordpress.org/plugins/yet-another-related-posts-plugin/faq/
http://blog.k-kansei.com/?p=728
個数未確認
テンプレートに記載
<?php
yarpp_related(array(
'post_type' => array('sekou', 'mycustompost'),
'show_pass_post' => false, // show password-protected posts
'past_only' => false, // show only posts which were published before the reference post
// 任意のテンプレートを利用する場合指定
//'template' => 'yarpp-template-xxxxxx.php', // either the name of a file in your active theme or the boolean false to use the builtin template
));
?>
https://wordpress.org/plugins/yet-another-related-posts-plugin/faq/
get_the_term_listの並び順をオーダー通りにファンクション
//echo get_the_term_list( $post->ID, ‘sekou_chiiki’, ”, ‘・’, ” );の並び順をオーダー通りに出力
function set_the_terms_in_order ( $terms, $id, $taxonomy ) {
$terms = wp_cache_get( $id, “{$taxonomy}_relationships_sorted” );
if ( false === $terms ) {
$terms = wp_get_object_terms( $id, $taxonomy, array( ‘orderby’ => ‘term_order’ ) );
wp_cache_add($id, $terms, $taxonomy . ‘_relationships_sorted’);
}
return $terms;
}
add_filter( ‘get_the_terms’, ‘set_the_terms_in_order’ , 10, 4 );
function do_the_terms_in_order () {
global $wp_taxonomies;
// the following relates to tags, but you can add more lines like this for any taxonomy
$wp_taxonomies[‘post_tag’]->sort = true;
$wp_taxonomies[‘post_tag’]->args = array( ‘orderby’ => ‘term_order’ );
}
add_action( ‘init’, ‘do_the_terms_in_order’);
福海クリエイトで事例一覧でタクソノミーにてカテゴリ一覧を表示させる。カレント有り。親カテでは親かてと小カテ小カテも同じ
追記カスタム
カテゴリなし非表示
'show_option_none' => '',
タイトル部分に親子分岐を追加して重複をコメントアウトした
<h2 class="title1">
<?php
echo $term->name; ?><?php if(is_tax('client') and !is_tax('client','d-marking-design')): echo ' 様'; endif; ?>
制作実績
<?php //後で追加子タームなら親カテ わかりにくくなるためあえてコード重複
//$termにはいってる情報で分岐
if ( $term->parent ) { // 親IDが入ってれば (子だったら)
?>
<span style="font-size:16px; font-weight:normal"> -
<!---TOP部分-->
<?php //親のIDを取得してターム情報を引き出す。
$ido=$term->parent;
$term2=get_term($ido,get_query_var( 'taxonomy' ));
?>
<?php
echo $term2->name;} ?> -
</span>
</h2>
<div style="clear:both"></div>
<div style="margin-top:15px; text-align:center; font-size:15px;"><i class="icon-coffee"></i>ご紹介できる制作物の一部をご紹介いたします。</div>
<?php //カテゴリー・タグ情報を取得(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;
//$term2=get_term($ido,get_query_var( 'taxonomy' ));
?>
<div class="sekou_cate_box" style="margin-top:20px;">
<ul>
<li class="parent">
<a href="<?php //子 親のターム情報からターム名とリンクを引き出す。
echo get_term_link($term2->slug,get_query_var( 'taxonomy' )); ?>
">
<?php
echo $term2->name; ?>
</a>
</li>
<!---一覧部分-->
<?php
wp_list_categories( array(
'title_li' => '',
'taxonomy' => get_query_var( 'taxonomy' ),
'child_of' => $term->parent,//親のIDを出力
'hide_empty' => 0,
'show_option_none' => '',
) );
}
else { //親だったらそのまま出力
?>
<!---TOP部分-->
<div class="sekou_cate_box" style="margin-top:20px;">
<ul>
<li class="parent">
<a href="<?php //親
echo get_term_link($term->slug,get_query_var( 'taxonomy' )); ?>
">
<?php
echo $term->name; ?>
</a>
</li>
<!---一覧部分-->
<?php
wp_list_categories( array(
'title_li' => '',
'taxonomy' => get_query_var( 'taxonomy' ),
'child_of' => $term->term_id,
'hide_empty' => 0,
'show_option_none' => '',
) );
}?>
</ul>
</div>
<div style="margin-top:15px; text-align:center; font-size:15px;"><i class="icon-coffee"></i>ご紹介できる制作物の一部をご紹介いたします。</div>
<?php //カテゴリー・タグ情報を取得(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;
$term2=get_term($ido,get_query_var( 'taxonomy' ));
?>
<div class="sekou_cate_box">
<ul>
<li class="parent">
<a href="<?php //子 親のターム情報からターム名とリンクを引き出す。
echo get_term_link($term2->slug,get_query_var( 'taxonomy' )); ?>
">
<?php
echo $term2->name; ?>
</a>
</li>
<!---一覧部分-->
<?php
wp_list_categories( array(
'title_li' => '',
'taxonomy' => get_query_var( 'taxonomy' ),
'child_of' => $term->parent,//親のIDを出力
'hide_empty' => 0,
) );
}
else { //親だったらそのまま出力
?>
<!---TOP部分-->
<div class="sekou_cate_box">
<ul>
<li class="parent">
<a href="<?php //親
echo get_term_link($term->slug,get_query_var( 'taxonomy' )); ?>
">
<?php
echo $term->name; ?>
</a>
</li>
<!---一覧部分-->
<?php
wp_list_categories( array(
'title_li' => '',
'taxonomy' => get_query_var( 'taxonomy' ),
'child_of' => $term->term_id,
'hide_empty' => 0,
) );
}?>
</ul>
</div>
css
/*施工例カテゴリ*/
.sekou_cate_box{ font-size:12px; margin-top:10px;}
.sekou_cate_box ul{
margin: 0px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 10px;
padding-left: 0px;
overflow: hidden;
}
.sekou_cate_box li{
float: left;
list-style-type: none;
padding: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 10px;
margin-left: 0px;
}
.sekou_cate_box li a{
display:block;
border: 1px solid #CCC;
margin-right: 10px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding-top: 5px;
padding-right: 8px;
padding-bottom: 5px;
padding-left: 8px;}
.sekou_cate_box li a:hover{ text-decoration:none;
background-color:#FF6A29;
color:#FFF}
.parent a{ color:#FFF;
background-color:#06338F;}
.sekou_cate_box li.current-cat a{color:#FFF;
background-color:#06338F;}
福海クリエイト 施工カテゴリ カスタムタクソノミーに親子関係(階層)を持たせ、複数選択したタームの並び順を親>子の順番に表示する
ファンクション
4.4.2修正版コード
sekou_catの部分はタクソノミー名<div class="sekou_cate_box"> <?php $parents = getRootTaxonomies( get_the_terms( $post->ID,"sekou_cat"), "0" ); foreach($parents as $pv){ echo "<ul>\n"; echo '<li class="parent"><a href="/sekou_cat/'.$pv->slug.'">'.$pv->name.'</a></li>'."\n"; //echo "<li>\n"; foreach($pv->children as $ck=>$cv){ echo '<li><a href="/sekou_cat/'.$cv->slug.'">'.$cv->name.'</a></li>'."\n"; } //echo "</li>\n"; echo "</ul>\n"; } ?> </div>css
/*施工例カテゴリ*/ .sekou_cate_box{ font-size:12px; margin-top:10px;} .sekou_cate_box ul{ margin: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; overflow: hidden; } .sekou_cate_box li{ float: left; list-style-type: none; margin:0px; padding:0px; } .sekou_cate_box li a{ display:block; border: 1px solid #CCC; margin-right: 10px; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; padding-top: 5px; padding-right: 8px; padding-bottom: 5px; padding-left: 8px;} .sekou_cate_box li a:hover{ text-decoration:none; background-color:#FF6A29; color:#FFF} .parent a{ color:#FFF; background-color:#06338F;}参考http://tipsbear.com/wordpress-taxonomy-get-terms-listing-in-order-of-parent-child/
保護中: FC2からWordPressに引越
保護中: 0561navi制作時に作ったユーザーアーカイブとかのコード類
コンタクトフォーム 必須 カウント 文字数制限
<div class="hisu">必須</div>
.hisu{ display:inline-block;
background-color:#f1b32d;
color:#FFF;
font-size:12px;
padding-left:10px;
padding-right:10px;}
[textarea* your-message minlength:10 maxlength:140] [count your-message]
[textarea* your-message minlength:10 maxlength:140] [count your-message down]
EWWW Image Optimizerの使い方
http://afirika.net/ewww-image-optimizer
jquery.page-scroller-309.js について
jquery.page-scroller-309.js について
http://coliss.com/articles/build-websites/operation/javascript/296.html
フィクスドしたヘッドスペースがあるため
-50などとした場合
ページ移管する際、ちゃんとしたマージンがとられないようだ。。
そのため
クラス#go1 のマージンをそのぶんとってやらなければならない。
ページ移管して到達したい場所のマージン・パディングを
#をスクロールさせないこーどもあったのでメモ
<a href="#h2-01" class="nopscr">h2-01に移動</a>(除外対象)
WP Fastest Cache はhtaccessを書き換えるためローカルでは動作しない
全てのデータをDLして
そのままローカルで使用する際は注意!
プラグイン 気になった
http://netaone.com/wp/wordpress-plugin-first/
Yoast SEO seoプラグイン
Shortcoder 冒頭 シメ addクイックタグみたいな
TablePress テーブル
Meta Slider スライド
Image Widget サイドバー画像
Easy FancyBox ライトボックス
WP Social Bookmarking Light
Flamingo
WP BASIC Auth
他
WP Admin UI Customize
営業日カレンダー改造
2020 変更 警告でるから
//分岐改造 初期画面その月から
$today = date("Y/m/d");
$today_m = date("n");
$today_y = date("Y");
if(!empty($_GET['year'])){ //空でなければ
$input_y = $_GET['year'];
if($input_y < 1970){
$dogg = $today_m;
}
elseif($input_y < $today_y){
$dogg = 1;
}
elseif($input_y > $today_y){
$dogg = 1;
}
elseif($input_y == $today_y){
$dogg = 1;
}
}
else{
$dogg = $today_m;
}
for ($i=$dogg;$i<13;$i++) :
//元
//for ($i=1;$i<13;$i++) :
2015.11.02下段追記
//分岐改造 古いカレンダーは表示されない
$today = date("Y/m/d");
$today_m = date("n");
$today_y = date("Y");
$input_y = $_GET['year'];
if($input_y < 1970){
$dogg = $today_m;
}
elseif($input_y < $today_y){
$dogg = 1;
}
elseif($input_y > $today_y){
$dogg = 1;
}
elseif($input_y == $today_y){
$dogg = 1;
}
else{
$dogg = $today_m;
}
for ($i=$dogg;$i<13;$i++) :
//元
//for ($i=1;$i<13;$i++) :
多分初期状態つまりカレンダーを読み込んだ状態はyearが0ないし1970よりすくない
だもんで現在の年を取得して
初期読み込みページなら
今日の月を取得して今月から表示
その他はその年すべだす
って分岐追加
すげ〜!
おまけ
ポジションアブソルトで画面の真ん中
1055行目に
target="_blank" rel="nofollow"
追記でいべんとURLはブランク
wordpressが買収したプラグイン
http://jp.techcrunch.com/2015/05/20/20150519automattic-buys-woocommerce-the-popular-plugin-for-turning-wordpress-into-a-store/
セキュリティ
BruteProtect
ecサイト
WooCommerce
ラミールさんで最適化させたりしたメモ
WP Fastest Cacheを入れても遅い
google 速度 テスト
https://developers.google.com/speed/pagespeed/insights/
モバイルフレンドリーテスト
https://www.google.com/webmasters/tools/mobile-friendly/?url=http%3A%2F%2Fdoggstarpromotion.info%2F
WPデフォ リダイレクト解説
http://rensrv.com/wp/wp-auto-redirect-pattern/tag/
まずパーマーリンクの変更だかブログ記事とページは
一応Redirectionsを入れてから
デフォルトかたポストネームに変更したが自動でリダイレクトされた301らしい
カスタムポストに設置したタクソノミーもとんだ。
但しカスタムポストタイプは旧URLでもアクセスできるが
新URLへは自動で飛ばない
本気だすなら全部転送させるべし
しかし
アクセスはできるが 飛ばない、 新URLでサイト内では見れるので
流れは消えないし、ページが増えた感じになって
そのうち旧URLがどこからもリンクされないのでアクセスできなくなるはずなのでまつ。
確認はsite:http://www.remile.jp/で
ogイメージサイズは470×246
複数せっていOK
シェア時のみ選択可能
og設定はフォーマットプラン参照
ラミールさんの管理画面
wp file cashを切るととても遅かった。
何のプラグインが重いか測るプラグインいれて P3 (Plugin Performance Profiler)
シンプルライトボックスだったので wp-jquery-lightboxに変更
「但しwp-jquery-lightboxにてモバイルcss用に
body div{
max-height: 100%; }
を使用する場合は
body div{
max-height: 200%; }
など大きくすると暗くなる画面が広くなるので
調整する。」
それでも遅かった。
良くあるトラブルで
バージョンアップ時に
wpfilecashやデータベースキャッシュリロードFIXなどをおんのままだと
アップしてからデータベースが最新ですとかなって
プラグインフォルダを消さなければ
ログイン出来なくなる。たたあったので
使用控えてた。タームオーダーも効かないし(WPFILECASH)
またアップグレードしてなったので(WPFILECASH)消す
ログイン
重いので調査わからない
管理画面が重いので
(WPFILECASH)を再インスト
インスト出来て 有効かできてから
プラグインフォルダから削除してら
なんか正常に動いた気がした。
テーマファイル画像をロスレス圧縮するアプリを購入
Lossless Photo Squeezer
こいつでjpgとか1/3とかにできる。
プウロードファイルをする場合は
プラグインEWWW Image Optimizer
をいれておく
Remove metadata
Hide Conversion Links
にチェック
あとJavaScript to Footer
ってやついれた
その他
http://viral-community.com/wordpress/lazy-load-5769/
Lazy Load
http://bazubu.com/speed-up-wordpress-site-19465.html
http://wp-kappa.com/bj-lazy-load/
http://kojikoji75.hatenablog.com/entry/2013/05/20/213140
WP Nofollow Post
これで記事内外部リンクをのふぉろーかできる
スマフォに軽く最適化させたメモ Dサイト
ファンクション
//モバイル分岐 タブレット含まず
function is_mobile(){
$useragents = array(
'iPhone', // iPhone
'iPod', // iPod touch
'Android.*Mobile', // 1.5+ Android *** Only mobile
'Windows.*Phone', // *** Windows Phone
'dream', // Pre 1.5 Android
'CUPCAKE', // 1.5+ Android
'blackberry9500', // Storm
'blackberry9530', // Storm
'blackberry9520', // Storm v2
'blackberry9550', // Storm v2
'blackberry9800', // Torch
'webOS', // Palm Pre Experimental
'incognito', // Other iPhone browser
'webmate' // Other iPhone browser
);
$pattern = '/'.implode('|', $useragents).'/i';
return preg_match($pattern, $_SERVER['HTTP_USER_AGENT']);
//モバイル分岐 タブレット含む
function is_mobile() {
$useragents = array(
'iPhone', // iPhone
'iPod', // iPod touch
'Android', // 1.5+ Android
'dream', // Pre 1.5 Android
'CUPCAKE', // 1.5+ Android
'blackberry9500', // Storm
'blackberry9530', // Storm
'blackberry9520', // Storm v2
'blackberry9550', // Storm v2
'blackberry9800', // Torch
'webOS', // Palm Pre Experimental
'incognito', // Other iPhone browser
'webmate' // Other iPhone browser
);
$pattern = '/'.implode('|', $useragents).'/i';
return preg_match($pattern, $_SERVER['HTTP_USER_AGENT']);
}
ヘッダー
<?php if (is_mobile()) : ?> <link href="/css/mobile.css" rel="stylesheet" type="text/css" /> <?php else: ?> <?php endif; ?>
moble.css
@charset "UTF-8";
/* CSS Document */
/*font-size:100%は親要素mに依存
最も親か??
いや直上の指定してある親だ
なにも親がしていしていなければ
ボディー
ボディーもしていなければ
ブラウザ依存
*/
.blog_con{ font-size:120%!important}
.blog_titel_min{font-size:100%!important}
body{ font-size:16px;}
/*.top_titel,*/
/*.top_sub_titel,*/
/*.top_sub_span,*/
.color_blue,
.top_box p,
.top_con p,
.top_p,
.jirei_sub_title
{font-size:150%!important}
.set_day_all{font-size:150%!important}
.set_day{ width:auto; margin-right:30px;}
.jirei_disp_con{ font-size:100%!important}
body #wp_page_numbers li a{ font-size:300%!important;
padding:30px!important;}
直で埋め込んであった改行削除コード
<?php if (is_mobile()) : ?>
<style type="text/css">
.smap br { display:none;
}
</style>
<?php else: ?><?php endif; ?>
事例ページなどをpで最適化し
pを150%などにした。
基本csss
/*モバイル用
文字が大きくならない*/
body div{
max-height: 100%; }
wordpress キャッシュプラグインと 画像圧縮プラグイン サイト速度検査
WP Fastest Cache
http://webshufu.com/wp-fastest-cache/
http://pochilog.jp/2015/07/post-3139/
http://webshufu.com/wp-fastest-cache/
モバイルはキャッシュしない
調査 developers.google.com
https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fdoggstarpromotion.info%2F&tab=desktop
画像のロスレス圧縮
EWWW Image Optimizer
http://webkaru.net/wordpress/plugin-ewww-image-optimizer/
EWWW Image Optimizerで画質が劣化しない設定と使い方
http://afirika.net/ewww-image-optimizer
画像圧縮プラグイン使い方
アンドロイド スマフォ クロームにて 文字サイズが大きくなる件
http://www.seomode.jp/html-css/2014/06/25/3339/
このサイトによるとviewportが数字で指定してある場合になる
対処法は
max-height: 100%;
全体のdivにかける
body div{
max-height: 100%; }
ただし
大きくなってほしい場合もあるが
#main_contents div{ max-height:none!important}
では駄目なようだ
一度100%で設定してしまうと
noneでも大きくならない
但し
一度
max-height: 100%; で指定して
のちにスマフォ用の分岐をいれていけば
いいのかなと思う
かってに大きくなると
こまるので
追記
ポップアップのdivが表示おかしくなったので たしか
/*モバイル用
文字が大きくならない*/
body div{
max-height: 200%; }
とした
また
iPhoneで文字が勝手に大きくなるのは
body {
-webkit-text-size-adjust: 100%;
}
こちら 同じ記事かくわ