2012年8月17日 星期五
wordpress 後台更改選項或自製後台
//更改選單位置
function custom_menu_order($menu_order) {
if (!$menu_order) return true;
return array(
'index.php',
'edit.php',
'edit.php?post_type=services',
'edit.php?post_type=work',
'edit.php?post_type=page',
);
}
add_filter('custom_menu_order', 'custom_menu_order');
add_filter('menu_order', 'custom_menu_order');
//更改底下說明
function change_footer_content() {
echo '感謝您使用我們的系統. 如果您需要請聯繫我們, 很好設計(studio.goods@gmail.com).';
}
add_filter('admin_footer_text', 'change_footer_content');
//刪除不必要後台功能,但用了更改分類會中猴
/*function remove_menu_pages() {
remove_menu_page('link-manager.php');
remove_menu_page('edit-comments.php');
}
add_action( 'admin_init', 'remove_menu_pages' );*/
wordpress 更多欄位請愛用Custom Fields(plugin)讓你無敵
wordpress 需要更多欄位請愛用Custom Fields(plugin)讓你無敵
例如
你需要很多複選框checkbox
你需要欄位可以選顏色 他就有colorpick
還有一個很賊的repeat fields可以再一則文章裡
上重複性的資料~~~多麼棒啊~但這要25美金~~我還沒買
例如
你需要很多複選框checkbox
你需要欄位可以選顏色 他就有colorpick
還有一個很賊的repeat fields可以再一則文章裡
上重複性的資料~~~多麼棒啊~但這要25美金~~我還沒買
wordpress 用了wp_query但卻跟基本設定的每頁數量不同,導致分頁pagenavi出錯
wordpress 用了wp_query但卻跟基本設定的每頁數量不同,導致分頁pagenavi出錯
舉例
我新創一個$wp_query
$wp_query = null;
$wp_query = new WP_Query();
$showposts = 2;
$args = array(
'post_type' => 'news_post',
'posts_per_page' => $showposts,
'paged' => $paged
);
query_posts($args);
然後在下面執行迴圈
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
//肚傷心
<?php endwhile ?>
<?php endif ?>
再來<?php native_pagenavi(); ?>//分頁導覽
但是我在基本後台管理設定 每頁出現9篇
而我這裡想要每頁出現2篇
我這個news_post只有4篇數量
開始出現bug了
第一頁會2篇 也有2分頁 很棒
但是按到第2頁時 出現404
後來搞很久才發現
wp會預設用台數量來使用
也就是第2頁時 他會2x9=18
但我並沒有18個品項我只有4個阿 於是就出現404
所以在國外找到解決辦法
http://wordpress.stackexchange.com/questions/7687/pagination-with-wp-query-is-buggy-working-for-some-pages-but-not-the-others
在function.php加入底下code
他們是這麼說的
wp會有預設的query,因此可以直接更改或替換query
所以上面的code就是
"當你下的$wp_query的category_name是'latest-news'時 就會自動替換成每頁4個"
舉例
我新創一個$wp_query
$wp_query = null;
$wp_query = new WP_Query();
$showposts = 2;
$args = array(
'post_type' => 'news_post',
'posts_per_page' => $showposts,
'paged' => $paged
);
query_posts($args);
然後在下面執行迴圈
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
//肚傷心
<?php endwhile ?>
<?php endif ?>
再來<?php native_pagenavi(); ?>//分頁導覽
但是我在基本後台管理設定 每頁出現9篇
而我這裡想要每頁出現2篇
我這個news_post只有4篇數量
開始出現bug了
第一頁會2篇 也有2分頁 很棒
但是按到第2頁時 出現404
後來搞很久才發現
wp會預設用台數量來使用
也就是第2頁時 他會2x9=18
但我並沒有18個品項我只有4個阿 於是就出現404
所以在國外找到解決辦法
http://wordpress.stackexchange.com/questions/7687/pagination-with-wp-query-is-buggy-working-for-some-pages-but-not-the-others
在function.php加入底下code
add_action( 'pre_get_posts', 'wpse7687_pre_get_posts' );
function wpse7687_pre_get_posts( &$wp_query ) {
if ($wp_query->query_vars['category_name'] == 'latest-news'){
$wp_query->query_vars['posts_per_page'] = 4;
}
}
他們是這麼說的
wp會有預設的query,因此可以直接更改或替換query
所以上面的code就是
"當你下的$wp_query的category_name是'latest-news'時 就會自動替換成每頁4個"
wordpress 如果有用post_type 請愛用archive.php
wordpress 如果有用post_type 請愛用archive.php
而若使用post_type ,網址就是
xxx.com.tw/post_type的名稱/
xxx.com.tw/post_type的名稱/page/2
就不會跟
xxx.com.tw/ category /page/2
搞混了
而若使用post_type ,網址就是
xxx.com.tw/post_type的名稱/
xxx.com.tw/post_type的名稱/page/2
就不會跟
xxx.com.tw/ category /page/2
搞混了
wordpress WP_Query不同post type選擇內容
<?php
$args = array(
'post_type' =>'work',
'category_name' => $myCat_slug[$i],
'order' => 'ASC'
);
$listQuery = new WP_Query( $args );
?>
<?php
query_posts('post_type=post');
?>
2012年8月9日 星期四
jquery 同時進行不同的動畫又不被取消或干擾
//同時進行不同的動畫又不被取消
alpha_40();
$("#about_content").animate({scrollTop: $('#about_human_WOW').offset().top-use_top_dis},{queue: false,duration: 3000,complete:function(){$("#goTop").fadeIn();}});
function alpha_40(){
$("#about_content").animate({opacity: 0.2},{queue: false,duration: 500,complete:function(){alpha_mid()}});
}
function alpha_mid(){
$("#about_content").animate({opacity: 0.2},{queue: false,duration: 2500,complete:function(){alpha_100()}});
}
function alpha_100(){
$("#about_content").animate({opacity: 1},{queue: false,duration:2000});
}
參考
http://alphasis.info/2011/09/jquery-api-animate-properties-options-queue/
2012年8月8日 星期三
CSS 上下置中
<style>
html,body{
margin:0;
height:100%;
width:100%;
}
#in_wrap{
margin:0 auto;
text-align:center;
}
</style>
<div id="in_wrap" class="greenBorder" style="display: table; width:800px;height: 100%; #position: relative; overflow: hidden;">
<div style=" #position: absolute; #top: 50%;display: table-cell; vertical-align: middle;">
<div class="greenBorder" style="#position: relative; #top: -50%; ">
這裡寫要使用的吧
</div>
</div>
</div>
2012年8月2日 星期四
jquery Iframe控制父視窗內容
parent.$ <-----這樣使用
parent.$.colorbox.close();
parent.$.address.value('contactOK');
parent.$.colorbox.close();
parent.$.address.value('contactOK');
訂閱:
文章 (Atom)