Get costom post type taxonomies

returning array of taxonomies about a custom post type like array( [0] =>taxonomy_name1, [1] =>taxonomy_name2 ) Code function _get_post_taxonomies($post_type) { // Passing an object // Why another var?? $output = …

How to register new post type with new taxonomy

这篇文章我将详细叙说如何在 WordPress 里运用 register_post_type 和 register_taxonomy添加新的文章类型和分类。 例如我们要新建一个文章类型叫 wine, 与之相对应的分类有两个,分别为  type, region。 所以我们大致需要这些数据,我把他们放到一个数组里: $plugin_name = ‘yaocms’; $portfolio_type = array( ‘type’ => ‘wine’, //注册在数据库里的文章类型 ‘name’ => __(‘Wine’, $plugin_name), //后台里显示菜单名称 ‘singular’ => __(‘Wine’, …

让 jQuery Datepicker 兼容 WordPress 和 WPML

没什么好说的,直接代码: jQuery(function($){ $.datepicker.regional[‘zh-hans’] = $.datepicker.regional[‘zh_CN’] = { closeText: ‘关闭’, prevText: ‘<上月’, nextText: ‘下月>’, currentText: ‘今天’, monthNames: [‘一月’,’二月’,’三月’,’四月’,’五月’,’六月’, ‘七月’,’八月’,’九月’,’十月’,’十一月’,’十二月’], monthNamesShort: [‘一’,’二’,’三’,’四’,’五’,’六’, ‘七’,’八’,’九’,’十’,’十一’,’十二’], dayNames: [‘星期日’,’星期一’,’星期二’,’星期三’,’星期四’,’星期五’,’星期六’], dayNamesShort: [‘周日’,’周一’,’周二’,’周三’,’周四’,’周五’,’周六’], dayNamesMin: [‘日’,’一’,’二’,’三’,’四’,’五’,’六’], weekHeader: ‘周’, dateFormat: …

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] => …

为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, …

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

  获取某个分类(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’ => …

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'”:””; …

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) ? …

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 …