icl_link_to_element and icl_object_id

Example usage Example Purpose Produced HTML <?php icl_link_to_element(10); ?> Link to page 10 (support page) <a href=”/support/”>Support</a> <?php icl_link_to_element(10,’post’,__(‘Get help’)); ?> Link to support page with an alternative link text …

修改WordPress里用户页的联系信息(Contact Info)

新旧界面对比,旧界面中的 aim,jabber,yim 被去掉了,加入了时下大家最熟悉的 facebook,twitter …… add_filter( ‘user_contactmethods’ , ‘update_contact_methods’ , 10 , 1 ); function update_contact_methods( $contactmethods ) { // Add new fields $contactmethods[‘phone’] = ‘Phone’; $contactmethods[‘mobile’] = ‘Mobile’; $contactmethods[‘address’] …

WPML Coding API and Custom Language Switcher

老是打不开这些页面,干脆复制到自己的地盘来了。方便自己也方便大家。 神马?WPML 是啥,自己百度吧! WPML offers functions that can be used in your WordPress theme to provide correct support for multilingual themes. Function Purpose Notes do_action(‘icl_language_selector’) Insert the drop down language …

WordPress debug code

WordPress debug 代码,把它放在function 文件里,就会在每页的页脚出现这个,包括当前模板,重写规则,Query 等等。 add_action( ‘template_include’, ‘_childtheme_print_template_name’ ); function _childtheme_print_template_name( $template_name ) { global $childtheme_template_name; $childtheme_template_name = $template_name; add_action( ‘wp_footer’, ‘childtheme_print_template_name’, 100 ); return $template_name; } function childtheme_print_template_name( ) …

Contact Form 7 的那些事儿

Customization of Contact Form 7 plugin Additional headers:You can input any header lines into the field and you can insert any tags into any place in each header line, just …

php数组随机排序

$array = array(‘A’,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’10’,’J’,’Q’,’K’); shuffle($array); //随机排序数组 print_r($array); //输出数组

WordPress Portfolio work with Isotope and Infinite Scroll

准备:需要的jQuery插件 Isotope: 神奇的布局精致的jQuery插件。演示 Infinite Scroll:无限滚动被称为autopagerize的,unpaginate,无尽的网页。但实质上,它是预取从随后出现的页面上的内容,并直接将其添加到用户的当前页面。http://www.infinite-scroll.com/ 演示 新建文章类型 portfolio 和 Portfolio 分类  function my_post_types() { register_post_type(‘portfolio’, array( ‘label’ => __(‘Portfolio’,’itc’), ‘singular_label’ => __(‘Portfolio’, ‘itc’), ‘_builtin’ => false, //’exclude_from_search’ => false, // Exclude from Search …

Get Featured Image with timthumb

$w = ‘350’; $h = ‘200’; if (has_post_thumbnail()) { $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), ‘full’); echo ”; } else { echo ”; }

php 法语字母排序

if($langcode == ‘fr’){ setlocale(LC_COLLATE, ‘fr_CA.utf8’); } ksort($array,SORT_LOCALE_STRING); 法语字幕有声调,往往在默认排序上会有些问题。上面的代码可以解决法语字母排序错误的问题。 同样可以应用于 sort asort 等等

Create wordpress custom widget

代码放到 functions.php 就可以在小工具里获得该 widget。 class weibo_widget extends WP_Widget { public function __construct() { // widget actual processes //get_popular_resource parent::__construct( ‘weibo_widget’, // Base ID ‘Weibo widget’, // Name array(‘description’ => __(‘Weibo …

Media, Audio, Video Player for wordpress

function yyy_html5_audio($url) { if (preg_match(‘/Firefox/’, $_SERVER[“HTTP_USER_AGENT”])) { // For religious reasons Firefox does not support MP3 format in HTML5 audio tag, use Flash player instead $embed = ”; } else …

Simple jquery horizontal accordion

有时候需要的功能很简单,不需要动不动就几千行的插件,就像这个水平手风琴效果。 html code Freebies Download free files to make your job easier. Tutorials Tips and tricks to help you keep up with the latest technology. Inspiration Get inspired by what …

.htaccess 完全手册

1.时区设置 有些时候,当你在PHP里使用date或mktime函数时,由于时区的不同,它会显示出一些很奇怪的信息。下面是解决这个问题的方法之一。就是设置你的服务器的时区。你可以在这里找到所有支持的时区的清单。 [code]SetEnv TZ Australia/Melbourne[/code] 2. 搜索引擎友好的301永久转向方法 为什么这是搜索引擎友好的呢?因为现在很多现代的搜索引擎都有能根据检查301永久转向来更新它现有的记录的功能。

2012年的第一天,我在厦门

这已经是一个半月前的事了,2011年的最后一个晚上的最后一小时,我乘坐厦门航空抵达了厦门。 2012年的第一天我独自一人逛了鼓浪屿,就这样,平平淡淡度过了本年度的第一天。

让Qtranslate 支持 Custom Taxonomy

If you wanted to automatically detect taxonomies, and then add translation edit fields here is some code: 如果你想要自动探测 Custom Taxonomy,然后给他们加上翻译字段, 把这段代码放在主题的 function.php 里。 function qtranslate_edit_taxonomies(){ $args=array( ‘public’ => true , ‘_builtin’ …

去除 wordpress 链接中的域名

上次说到去除一些不必需的 class 和 ID, 从上图看出,这些 domain name 似乎也是不必须的,如果像下图: 这样会不会更好呢,下面的代码可以实现这个效果。 add_filter(‘walker_nav_menu_start_el’ , ‘yao_walker_nav_menu_start_el’ , 10 , 2); function yao_walker_nav_menu_start_el($item_output, $item){ //print_r($item); $home_url = home_url(); $site_url = site_url(); preg_match(“/^(http:\/\/)?([^\/]+)/i”,site_url(), $matches); $domain = …

清理wordpress菜单里的 id 和 class

wordpress 默认的菜单会产生很多 id 和 class 在代码里,打多时候,这些都是不需要的。 通过下面2个滤镜,可以去除那些我们不需要的 class 和 ID add_filter(‘nav_menu_css_class’ , ‘special_nav_class’ , 10 , 2); function special_nav_class($classes, $item){ $current_and_home = array(“current-menu-item”, “menu-item-home”, ‘last’); $classes = array_intersect($item->classes,$current_and_home); //保留有需要的 class …