Month: April 2013
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 = ‘objects’; // name / objects $taxonomies = get_object_taxonomies($post_type); /*// Passing a string using get_post_type: return (string) post, page, custom… $post_type = get_post_type($post); $taxonomies = get_object_taxonomies($post_type,…
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’, $plugin_name), //单数形式 ‘capability’ => ‘page’, //兼容模式,page 或 post ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’, ‘page-attributes’), //默认支持的字段,依次是:标题,主编辑区域,特色图片,排序 ‘slug’ => ‘wine-view’, //显示在前端url里: https://yaoyingying.com/{$this slug}/文章名 ‘taxonomy’ => array( //分类学…
让 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: ‘yy-mm-dd’, firstDay: 1, isRTL: false, showMonthAfterYear: true, yearSuffix: ‘年’}; $.datepicker.setDefaults( $.datepicker.regional[ “<?php echo defined(‘ICL_LANGUAGE_CODE’)?ICL_LANGUAGE_CODE:WPLANG;?>” ] ); }); 最后一行,这儿由于 WPML 和 WORDPRESS 的语言静态变量不一样,值也不同,需要判断然后输出,输出的值可能是 zh-hans,或 zh_CN,所以在第一行声明了两个变量来存储翻译。
CarouFredSel中TouchSwipe不支持带链接的元素
http://caroufredsel.dev7studios.com/configuration.php caroufredsel 的配置页面里提到 swipe 这个属性:To enable this feature, you’ll need to include the jQuery.touchSwipe-plugin. 如果 HTML 结构是这样 <div class=”image_carousel”> <ul id=”carousel”> <li><img src=”slier.jpg”/><li> <li><img src=”slider2.jpg”/><li> </ul> </div> 你可以这样使这个幻灯片支持touchswipe <script> $(“#carousel”).carouFredSel({ auto : false, prev : ‘#c-prev’, next : ‘#c-next’, swipe : { onTouch : true, onMouse : true } }); </script> 倘若这个幻灯片的图片带来链接: <ul id=”carousel”> <li><a href=”foo.html”><img…