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 }?>

2013年8月27日 星期二

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]是取第一個

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不要加。