Author: 迎迎 姚

  • How to fix position absolute z-index bug in IE7

    How to fix position absolute z-index bug in IE7

    正常的我们做下拉菜单 和 幻灯片重叠在一起的时候,使用 z-index 就可以解决问题,正常的效果应该是这样: 但是天杀的 IE7 却是这样: 这时候任凭你怎么使用 position 和 z-index 都不会起作用! 可以到google搜索 ie7 position absolute z-index 一大堆解决方案。经常我几番研究,下面示范一个通俗易懂的解决方法: 先看一下我的代码结构: 这两个层的 z-index 的值大设置并没有多大关系,只要按照显示在上面的数字越大就可以了。 下面我们找到 mega menu 的根层 #header,给她家上两个css属性 {position: relative;z-index: 10;} 在找到 幻灯片 所在层的根层 #page ,加上 css 属性 {position: relative;z-index: 1;} 保存,测试,看看是不是在IE7 里也正常了。 无聊的可以拿下面的代码中各个浏览器里面试试,定能发现其中的奥妙,至于这是IE7 的什么bug,那就不管了~ <style><!– .parent{width:200px; height:200px; padding:10px;} .sub{text-align:right; font:15px Verdana;width:100px; height:100px;} .lt50{left:50px;top:50px;} –></style> <div…

  • How to make Popularity Posts Widget compatible with WPML

    How to make Popularity Posts Widget compatible with WPML

    In table $prefix_PopularityPostsWidget  The view record store here like this: There is WPML function wpml_get_language_information can get the post language information by post id, like this wpml_get_language_information($post->ID)   Array ( [locale] => fr_FR [text_direction] => [display_name] => Français [native_name] => Français [different_language] => ) Array ( [locale] => en_US [text_direction] => [display_name] => Anglais [native_name] => English [different_language] => 1 ) If it’s different language, the value will be true (1) Depand on this, now we can modify public function widget in class_popularity-posts-widget.php Inside function widget, find loop foreach ($rows as $row) Replace by the code between: ////////////// Loop /////////////////// foreach ($rows as $row) { } ////////////// End of loop…

  • 为WordPress[gallery]短标签里的图片链接添加更多属性

    为WordPress[gallery]短标签里的图片链接添加更多属性

    Add rel Attribute to Image Links in WordPress Galleries 如果你想给[ gallery ] 里的图片链接加上而外的属性, rel 或者 class 等等,去配合使用 fancybox、 lightbox 等 jQuery 插件。代码如下: If you want to use either Fancybox or Lightbox scripts for image galleries, you need to add the rel attribute to all full size image links. Here is how to do it: add_filter(‘wp_get_attachment_link’, ‘add_gallery_id_rel’); function add_gallery_id_rel($link) { global $post; return…

  • PHP多维数组根据内部元素排序

    PHP多维数组根据内部元素排序

    PHP multi array sort by an element nested inside 倘若让数组根据[data]元素的大小重新排序: $data = array( array( ‘name’=>’Julie’, ‘key’=>’64489c85dc2fe0787b85cd87214b3810’, ‘age’=>20 ), array( ‘name’=>’Martin’, ‘key’=>’bb07c989b57c25fd7e53395c3e118185’, ‘age’=>18 ), array( ‘name’=>’Lucy’, ‘key’=>’ab3aec6d954571c7551a186ea1cd98ff’, ‘age’=>100 ), array( ‘name’=>’Jessica’, ‘age’=>25, ‘key’=>’e1a118c9178aa3538f39a9c8131938ed’ ), ); 使用 usort 重排 class itcArraySort { private $arr = array(); public function __construct($arr) { $this->arr = $arr; } public function doSort($key,$order=’ASC’)…

  • 获取某个分类下所有文章相关的标签

    获取某个分类下所有文章相关的标签

      获取某个分类(Category)下所有文章相关的标签(TAGS) 首先获取分类下的所有文章: query_posts(array( ‘post_type’ => ‘portfolio’, ‘showposts’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘portfolio-class’, ‘terms’ => $the_taxonomy, ‘field’ => ‘term_id’, ) ), ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ) ); 去过所有posts对象: $portfolio_vars = $wp_query->posts; 这样就可以获取到每个文章的 ID $portfolio_var->ID; 可以通过这个ID 获取到每个文章相关的标签:wp_get_post_terms($portfolio_var->ID, $taxonomy); 然后就可以循环取出各个标题的属性,存储到新的$relate_terms数组里 $portfolio_vars = $wp_query->posts; foreach($portfolio_vars as $portfolio_var){ //$portfolio_ids[] = $portfolio_var->ID; $term_list = wp_get_post_terms($portfolio_var->ID,…

  • Simple WPML language switch

    Simple WPML language switch

    公司客户老喜欢吧 语言选择器 做成这样~ 麻烦~ function icl_post_languages(){ $languages = icl_get_languages(‘skip_missing=0&orderby=code’); if(1 < count($languages)){ $langs[] = ‘<div class=”languages”>’; foreach($languages as $l){ if($l[‘language_code’] == ‘zh-hans’) $l[‘language_code’] = “中文”; $active = $l[‘active’] == 1?”class=’active_language'”:””; $langs[] = ‘<a ‘.$active.’ href=”‘.$l[‘url’].'”>’.$l[‘language_code’].'</a>’; } $langs[] = ‘</div>’; echo join(“\n”, $langs); } } 文章( Post)和 分类目录(category)页面不显示多语言选择链接 if (icl_post_languages()): $post_types=get_post_types(array( ‘public’ => true, ‘_builtin’ =>…

  • WordPress Get Root Page ID

    WordPress Get Root Page ID

    this snipet will show you how to get root page id and title in wordpress! global $post; $parent_id = $post->post_parent; $post_id = $post->ID; $ancestors = get_post_ancestors($post_id); $root_id = (!empty($ancestors) ? array_pop($ancestors): $post_id); $child_of = $root_id; $widget_title = get_the_title($root_id);  

  • send_to_editor get audio address and id

    send_to_editor get audio address and id

    这个方法会导致 WordPress 编辑器原本的插入媒体功能失效! /* * To change this template, choose Tools | Templates * and open the template in the editor. */ add_filter(‘media_send_to_editor’, ‘media_editor’, 1, 3); function media_editor($html, $send_id, $attachment ){ //get the media’s guid and append it to the html //$post = get_post($send_id); //$html .= ”.$send_id.'”‘; $html = str_replace(‘<a’, ‘<a=”” smid=”.$send_id, $html); return $html;…

  • Backstretch Errot: has no method ‘backstretch’

    Backstretch Errot: has no method ‘backstretch’

    a simple jQuery plugin that allows you to add a dynamically-resized, slideshow-capable background image to any page or element Uncaught TypeError: Object function (e,t){return new v.fn.init(e,t,n)} has no method ‘backstretch’ maybe many guys got this error Maybe the issue is ’cause you put $.backstretch([“bg.jpg”]);   ahead of jquery.backstretch.js plugin, try switch the postion.

  • jQuery 向上弹出式菜单

    jQuery 向上弹出式菜单

    Slide Up Menu / jQuery 向上弹出式菜单 The jQuery Slide Up Menu it’s a good alternative to other existing menus giving the possibility to position the menu on the bottom of your header image or at the bottom of the window, acting like Windows Start Menu. You can let it behave like a normal menu or…