草窟设计

Wordpress, Drupal 二次开发~

  • 首页
    • On Trip
    • 心情日记
    • 代码人生
    • 前端技术
    • Linux-Server
  • 关于站长
    • 新浪微博
    • 我在人人网
    • About Me
    • My Google
    • My Flickr
  • WordPress
    • Qtranslate Flags Setting
  • Portfolio
    • MD5 加密
  • Div & Css
  • 分类目录

wordpress

Home > Blog > 去除 wordpress 链接中的域名

去除 wordpress 链接中的域名

Time Posted on 5, 一

上次说到去除一些不必需的 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 = $matches[0]; if( $domain == $home_url){ $replace = ''; }else{ $replace = str_replace($matches[0], '', site_url()); } $item->url = str_replace($home_url,$replace,$item->url);   $attributes = ! empty( $item->attr_title ) [...]

清理wordpress菜单里的 id 和 class

Time Posted on 3, 一

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 return $classes; }   add_filter('nav_menu_item_id' , 'special_nav_item_id' , 10 , 2); function special_nav_item_id($item_id, $item){ $item_id = ""; //去除 id return $item_id; } 清理之后如: 不过尚有 class=”" [...]

怎么让WordPress自定义菜单在新窗口打开

Time Posted on 14, 十二

首先到 blog/wp-admin/nav-menus.php 页面。勾选上 链接目标。 然后在下面的自定义菜单区域,点开单个菜单单元 搞定。 Happy? Rel 属性设置以此类推。

关闭 WordPress 自动更新

Time Posted on 10, 十一

实际上这是个插件叫 Disable Updates,但是想就这点代码直接写在主题的功能文件里倒来得更加方便:

WordPress Feeds 定制

Time Posted on 9, 十一

The Feed templates are located in the /wp-includes/feed-{type}.php files and include formats for rdf, rss, rss2 and atom. 这儿是一些默认的 rss 模板,定制自己的模板时可以参照。

WordPress Upload New Media “HTTP error”

Time Posted on 26, 十

版本是 3.2.1 在原本的服务器上运行无错,移植到新的服务器就有这个问题,大概就是服务器配置的缘故了。 官方上也相关的文章。http://wordpress.org/support/topic/25-imagemedia-uploader-problems 是apache Mod_Security 的缘故。如果你能够修改你服务器的httpd.conf文件的话,删除里面关于mod_security部分就可以了。不过多数wordpress玩家是没有权限修改这个文件的,那就只好修改.htaccess文件了。在.htaccess文件里面加上一行: <IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule> 这样就可以关闭 Mod_Security。

WordPress UTF8 中文截取

Time Posted on 17, 十

UTF8 中文截取 其中对字符串预先 __() 处理,可以从 qtranslate 中取出当前语言部分然后进行截取。 function utf8Substr($str, $from, $len) { if ($len == 0){ return __($str); }else{   return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s', '$1',__($str)); } } //use utf8Substr($recent["post_title"],0,14); function utf8_trim($str) {   $len = strlen($str);   for ($i=strlen($str)-1; $i>=0; $i-=1){ $hex .= ' '.ord($str[$i]); $ch = ord($str[$i]); if (($ch & 128)==0) return(substr($str,0,$i)); if (($ch & [...]

WordPress 如何修改密码保护表单的文字说明

Time Posted on 11, 十

This piece of code should do it for you. Place this code in your theme’s functions.php file. You can add customizations to the custom_password_form() function – just don’t use print or echo – the function must return a value. <?php add_filter( 'the_password_form', 'custom_password_form' ); function custom_password_form() { global $post; $label = 'pwbox-'.( empty( $post->ID ) [...]

wpautop WordPress 文章格式化

Time Posted on 12, 八

Changes double line-breaks in the text into HTML paragraphs (<p>…</p>). 把文章里的 2次换行 格式化成 html 段落(<p>…</p>). $foo (string) (required) The text to be formatted. 需要格式化的文章。 Default: None $br (boolean or integer) (optional) Preserve line breaks. When set to true, any line breaks remaining after paragraph conversion are converted to HTML . Line breaks within script and [...]

Get Labels for Advanced Custom Fields

Time Posted on 11, 八

Advanced Custom Fields for wordpress 是一个不错的插件,但是api 里只有 get fields,却没有get labels,对此,作者认为没有必要(作者的论坛上表示的)。一般情况是真的没必要。但是有会更好! 在配合 WPML 做多语言网站的时候就大有用处了,可以设置不同的 Field Label 用相同的 Field Name,这样就可以实现切换语言的时候自动切换 Field Label,而用相同的 get field 获取不同 label 下面的值。 吧下面的代码放进header.php 或这 function.php function get_acf_labels($name = null, $post_id) {   global $wpdb;   //SELECT name, label FROM wp_acf_fields as waf left jolin wp_acf_values as wav on wav.field_id = waf.id where [...]
« Older entries

给我钱钱~

如果你举得我的文章对你有帮助,欢迎向我支付一小笔金钱作为回报。

数额无大小,这是我的收款主页http://me.alipay.com/yaoyingying

一看就知道是灰机~

凯特葛妮亚~

  • Featured Stories (12)
  • Linux-Server (40)
  • On Trip (21)
  • 代码人生 (76)
    • Drupal (2)
    • Wordpress (4)
  • 前端技术 (27)
    • Jquery (9)
  • 心情日记 (62)
    • Have a Joke (7)
    • 随便写写 (19)
  • 电脑硬件 (7)

最近扯的蛋

  • 去除 wordpress 链接中的域名
  • 清理wordpress菜单里的 id 和 class
  • Drupal7 获取自定义字段的值
  • WordPress 只显示当前用户的文章
  • 怎么让WordPress自定义菜单在新窗口打开
  • 7步在 Drupal 7 中建立 Nivo Slider
  • 探测设备系统
  • 关闭 WordPress 自动更新
  • WordPress Feeds 定制
  • WordPress Upload New Media “HTTP error”
  • PHP数据类型转换
  • WordPress UTF8 中文截取
  • WordPress 如何修改密码保护表单的文字说明
  • Qtranslate With function __() and _e()
  • Ubuntu 163 Sources List
  • wpautop WordPress 文章格式化
  • Get Labels for Advanced Custom Fields
  • Post Formats of WordPress
  • wp_head() 函数优化
  • 正式开始 WordPress 了!

坑爹啊~

2012 年一月
日 一 二 三 四 五 六
« 十二    
1234567
891011121314
15161718192021
22232425262728
293031  

一堆破图

climbing 11071916154d64dd6d2895dbf2 1107191553866bdca3b170ba8e 11071915331d34fb0b6be0ec85 1107191520900842a89d924b3f 11071909057825144e19ede8a4 IMG_4987 IMG_5018 ME

在过去的时光里

  • 2012 年一月 (2)
  • 2011 年十二月 (4)
  • 2011 年十一月 (3)
  • 2011 年十月 (4)
  • 2011 年九月 (1)
  • 2011 年八月 (6)
  • 2011 年六月 (2)
  • 2011 年五月 (9)
  • 2011 年四月 (2)
  • 2011 年三月 (2)
  • 2011 年一月 (7)
  • 2010 年十二月 (8)
  • 2010 年十一月 (4)
  • 2010 年十月 (5)
  • 2010 年九月 (4)
  • 2010 年八月 (7)
  • 2010 年七月 (8)
  • 2010 年六月 (2)
  • 2010 年五月 (3)
  • 2010 年四月 (6)
  • 2010 年三月 (7)
  • 2010 年二月 (5)
  • 2010 年一月 (2)
  • 2009 年十二月 (7)
  • 2009 年十一月 (7)
  • 2009 年九月 (10)
  • 2009 年八月 (18)
  • 2009 年七月 (15)
  • 2009 年六月 (17)
  • 2009 年五月 (19)
  • 2009 年四月 (14)
  • 2009 年三月 (25)

像新浪一样SB

一群流氓~

  • Hpyer 的未知空间
  • Just4Memory
  • php教程
  • web蓝草博客
  • 上海收缩机
  • 动漫穷小子网
  • 天时表行
  • 影视爱好者
  • 教育培训网
  • 水平网
  • 盒子UI设计
  • 老姚博客
  • 苏州丁氏养蜂场
  • 赵子仓
  • 那些花儿

一切都是浮“云”

ajax Apache apt-get Chinajoy CSS Debian dedecms error firefox HeidiSQL htaccess html IE6 javascript jQuery lamp linux mail mod_rewrite mysql mysql5 MySQL Front php phplist phpmyadmin postfix thinkphp Ubuntu wordpress WordPress Theme 京腔 代码 年轻的时候很傻很天真 户外 摄影 数据库 李玉刚 歌词 歌词翻译 盛世霓裳 示例 翻译 芳华绝代 视频 音乐

分析在此~

png png

© 2012 Yao Yingying