勿再使用舊php 例如$HTTP_GET_VARS
改成$_GET
改成$_SESSION
不然很多會出錯
2014年6月14日 星期六
2014年5月29日 星期四
TAG
物件裡的TAG
<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ' ';
}
}
?>
列出所有TAG
<?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
echo '<li class="name ">' . $tag->name.'</li> ';
}
}
?>
<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ' ';
}
}
?>
列出所有TAG
<?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
echo '<li class="name ">' . $tag->name.'</li> ';
}
}
?>
2014年5月6日 星期二
jquery address 能for jquery1.9以上的版本
https://raw.githubusercontent.com/asual/jquery-address/master/src/jquery.address.js
2014年2月9日 星期日
Warning: Missing argument 2 for wpdb::prepare()
找到問題頁面有包含
$wpdb->prepare
然後可能原本是這樣
return $wpdb->get_var($wpdb->prepare("SELECT COUNT(option_name) FROM $wpdb->options WHERE option_name = '$option';"));
只有一個參數
改成
$CC='$option';
return $wpdb->get_var($wpdb->prepare("SELECT COUNT(option_name) FROM $wpdb->options WHERE option_name = %d;",$CC));
$wpdb->prepare
然後可能原本是這樣
return $wpdb->get_var($wpdb->prepare("SELECT COUNT(option_name) FROM $wpdb->options WHERE option_name = '$option';"));
只有一個參數
改成
$CC='$option';
return $wpdb->get_var($wpdb->prepare("SELECT COUNT(option_name) FROM $wpdb->options WHERE option_name = %d;",$CC));
2013年10月15日 星期二
2013年9月4日 星期三
wordpress 下一篇 上一篇 寫法
<?php
$next_post = get_next_post(ture);
$prev_post = get_previous_post(ture);
if (!empty( $prev_post )){?>
<div class="next-article"><a href="<?php echo get_permalink( $prev_post->ID ); ?>"><span>Next</span><i class="icon-nex-article-arr"></i></a></div>
<?php }else{?>
<?php
//目前分類的名稱
$category = get_the_category();
$args = array(
'post_type' => 'post',
'showposts' => 1,
'cat' => $category[0]->term_id
);
$top_query = new WP_Query($args); ?>
<?php while($top_query->have_posts()) : $top_query->the_post(); ?>
<div class="next-article"><a href="<?php echo get_permalink(get_the_ID()); ?>"><span>Next</span><i class="icon-nex-article-arr"></i></a></div>
<?php endwhile; ?>
<?php wp_reset_postdata();?>
<?php }?>
$next_post = get_next_post(ture);
$prev_post = get_previous_post(ture);
if (!empty( $prev_post )){?>
<div class="next-article"><a href="<?php echo get_permalink( $prev_post->ID ); ?>"><span>Next</span><i class="icon-nex-article-arr"></i></a></div>
<?php }else{?>
<?php
//目前分類的名稱
$category = get_the_category();
$args = array(
'post_type' => 'post',
'showposts' => 1,
'cat' => $category[0]->term_id
);
$top_query = new WP_Query($args); ?>
<?php while($top_query->have_posts()) : $top_query->the_post(); ?>
<div class="next-article"><a href="<?php echo get_permalink(get_the_ID()); ?>"><span>Next</span><i class="icon-nex-article-arr"></i></a></div>
<?php endwhile; ?>
<?php wp_reset_postdata();?>
<?php }?>
2013年8月27日 星期二
如果the_content(),沒有出現任何output
請服用
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>.
//the_content();
<?php endwhile; ?>
<?php endif; ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>.
//the_content();
<?php endwhile; ?>
<?php endif; ?>
2013年8月26日 星期一
目前的CATEGORY NAME(只勾選一個的話)
//目前分類的名稱
<?php
$category = get_the_category();
echo $category[0]->cat_name;
?>
//目前分類的母分類名稱
<?php
$category=get_the_category();
$parent_cat= $category[0]->category_parent;
$thisCat= get_category($parent_cat,false);
echo $thisCat->name;
?>
//以上測試過 適用於該產品分類只屬於一個並沒有同時屬於第二個分類,因為[0]是取第一個
<?php
$category = get_the_category();
echo $category[0]->cat_name;
?>
//目前分類的母分類名稱
<?php
$category=get_the_category();
$parent_cat= $category[0]->category_parent;
$thisCat= get_category($parent_cat,false);
echo $thisCat->name;
?>
//以上測試過 適用於該產品分類只屬於一個並沒有同時屬於第二個分類,因為[0]是取第一個
2013年8月22日 星期四
list category
如果不愛<?php wp_list_categories( $args ); ?>
請服用以下
<?php $args=array(
'orderby' => 'name',
'order' => 'ASC',
'show_count' => true,
'title_li' => '',
'child_of' => 5,
);
$categories = get_categories($args);
foreach($categories as $category) {
$output = '<li>';
$output .= '<a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
echo $output;
}
?>
2013年6月27日 星期四
以往可以用加上 -webkit-text-size-adjust : none 解決,但新版 Chrome 已經將 -webkit-text-size-adjust 支援移除。所以必須改以 -webkit-transform : scale( ... ) 處理, scale 中的數字為要設定的字型大小除以 12px ,例如 9px 就是 9 / 12 = 0.75 。請注意 display : inline 無法 transform ,請視情況加上 display : inline-block ,且目前看來 transform 會破壞字的間距:
-webkit-transform : scale(0.75);
from http://blog.xuite.net/vexed/tech/59449347-Chrome+font-size+%E5%B0%8F%E6%96%BC+12px
2013年6月19日 星期三
解決fadeIn與fadeOut在mouseover與out的動作後會持續重複動畫
$(".navleng").mouseover(function() { //When trigger is clicked...
$(this).find(".head_subnav").fadeIn(300).slideDown('fast'); //Drop down the subnav on click
$(this).hover(function() {
}, function(){
$(this).find(".head_subnav").stop(true).fadeOut(300).slideUp('fast');
});
});
在hover的相反裡加入.stop(true)即可,然後剛滑入時的fadeIn不要加。
$(this).find(".head_subnav").fadeIn(300).slideDown('fast'); //Drop down the subnav on click
$(this).hover(function() {
}, function(){
$(this).find(".head_subnav").stop(true).fadeOut(300).slideUp('fast');
});
});
在hover的相反裡加入.stop(true)即可,然後剛滑入時的fadeIn不要加。
2013年5月2日 星期四
mysql中如何篩選出非重複資料
請參考
http://xcy.17cha8.cn/read.php/441.htm
http://xcy.17cha8.cn/read.php/441.htm
使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供有distinct这个关键字来过滤掉多余的重复记录只保留一条,但往往只用它来返回不重复记录的条数,而不是用它来返回不重记录的所有值。其原因是distinct只能返回它的目标字段,而无法返回其它字段
下面先来看看例子:
table
id name
1 a
2 b
3 c
4 c
5 b
id name
1 a
2 b
3 c
4 c
5 b
比如我想用一条语句查询得到name不重复的所有数据,那就必须使用distinct去掉多余的重复记录。
select distinct name from table
得到的结果是:
得到的结果是:
name
a
b
c
a
b
c
好像达到效果了,可是,我想要得到的是id值呢?改一下查询语句吧:
select distinct name, id from table
结果会是:
id name
1 a
2 b
3 c
4 c
5 b
1 a
2 b
3 c
4 c
5 b
试了半天,也不行,最后在mysql手册里找到一个用法,
用group_concat(distinct name)配合group by name实现了我所需要的功能 5.0才支持的.
突然灵机一闪,既然可以使用group_concat函数,那其它函数能行吗?
赶紧用count函数一试,成功, 现在将完整语句放出:
select *, count(distinct name) from table group by name
结果:
id name count(distinct name)
1 a 1
2 b 1
3 c 1
1 a 1
2 b 1
3 c 1
再顺便说一句,group by 必须放在 order by 和 limit之前,不然会报错。。。OK了
2013年3月16日 星期六
作品連結
吾穀茶糧:http://www.siidcha.com/
MARCO VICCI:http://marcovicci.com.tw/
宮原眼科:http://www.miyahara.com.tw/
很好設計:http://www.goods-design.com.tw/
美可特品牌企劃設計:http://www.victad.com.tw/
兩隻老虎設計工作室:http://www.2tigersdesign.com/
百山渡:http://www.130pure.com/
麗絲凱莉:http://www.lizkelly.com.tw/
MARCO VICCI:http://marcovicci.com.tw/
宮原眼科:http://www.miyahara.com.tw/
很好設計:http://www.goods-design.com.tw/
美可特品牌企劃設計:http://www.victad.com.tw/
兩隻老虎設計工作室:http://www.2tigersdesign.com/
百山渡:http://www.130pure.com/
麗絲凱莉:http://www.lizkelly.com.tw/
2013年1月14日 星期一
scrolltop chrome firefox某一項無作用
原本這樣用
$('body').stop().delay(800).stop().animate({
scrollTop:0
}, 800);
但常常firefox無作用
於是加入下面html就可
$('body,html').stop().delay(800).stop().animate({
scrollTop:0
}, 800);
2013年1月10日 星期四
wordpress取得目前POST文章的路徑名稱 或是文章 ID
<?php
$pagename = get_query_var('pagename');
if ( !$pagename && $id > 0 ) {
// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
$post = $wp_query->get_queried_object();
$pagename = $post->post_name;//目前文章 名稱
}
$postid = get_the_ID();//目前文章ID
?>
2012年10月12日 星期五
flash call js 居然一定要用localhost才能測試
//用flash IDE測試不出來 要用localhost的方式或是丟到網路上 反正就是要成為網路模式 不能本機測試
import flash.external.ExternalInterface;
stop();
ck_mc.addEventListener(MouseEvent.MOUSE_DOWN, overGameMc);
function overGameMc(e:MouseEvent){
//---確認是否能呼叫外部javascript--ok=>true,之後在執行mouseopen()方法;
trace('123');
ExternalInterface.call("cool");
}
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script language="javascript" >
var flashvars = {};
var params = {};
var attributes = {};
params.allowscriptaccess = "always";
attributes.id = "as3_js";
swfobject.embedSWF("trace.swf", "alt", "450", "450", "10.0.0", false, flashvars, params, attributes);
function cool(){
alert("cool");
}
</script>
<div class="as3">
<div id="alt"></div>
</div>
2012年9月20日 星期四
2012年9月19日 星期三
2012年9月11日 星期二
javascript只取數字 用正規表示
var str=$(".area_product").css('left');//出來會是312px
var reg=/[^\d]+/img;
str=str.replace(reg,"");
alert(str);//出來會是312
訂閱:
文章 (Atom)