在
wp-admin/admin-header.php
合适的地方增加如下代码
if (!is_blog_admin()) { ?> <link rel="stylesheet" id='hidemenu-css' href="<?php bloginfo('template_directory'); ?>/hidemenu.css" /> <?php } ?>
然后把hidemenu.css放在主题的目录下,编辑css
有啥别的好办法么?
在
wp-admin/admin-header.php
合适的地方增加如下代码
if (!is_blog_admin()) { ?> <link rel="stylesheet" id='hidemenu-css' href="<?php bloginfo('template_directory'); ?>/hidemenu.css" /> <?php } ?>
然后把hidemenu.css放在主题的目录下,编辑css
有啥别的好办法么?
水煮鱼的微信机器人不错,http://blog.wpjam.com/project/weixin-robot/
但是这个微信机器人如果你用ngg,那么显示图片会有点问题,做如下修改,会显示图片。
if(!function_exists('get_post_first_image')){ function get_post_first_image($post_content){ global $post, $wpdb; preg_match('@\\no images were found
@i', do_shortcode($post_content), $matches); if($matches){ $picture_id = $matches[1]; $sql="SELECT * FROM {$wpdb->prefix}ngg_pictures p left join {$wpdb->prefix}ngg_gallery g on p.galleryid=g.gid WHERE p.pid = ". intval( $picture_id ) . " ORDER BY sortorder, pid ASC"; $ngg_image = $wpdb->get_row( $sql ); return get_site_url()."/".$ngg_image->path."/thumbs/thumbs_".$ngg_image->filename; }else{ return false; } } }
有问题请留言。
一个wordpress用了ngg相册,大概有2万张图片,速度慢的不行,关掉了ngg,速度就正常了,于是写了段代码,兼容ngg gallery的singlepic写法,能正常显示图片,网站速度恢复正常。
莫名其妙的插件,怎么能把速度搞这么慢。这段代码可以用作NextGEN Gallery停用后的一个解决方案
<?php /* Plugin Name: fcuk ngg gallery Plugin URI: http://www.juyimeng.com Description: display pic without ngg Author: juhui Version: 1.0 Author URI: http://www.juyimeng.com/ */ function ngg_pic_replacer($content) { $search = "@\\no images were found
@i"; $content= preg_replace_callback( $search, replace_picture , $content,-1); return $content; } function replace_picture($matches) { global $post, $wpdb; $picture_id = $matches['id']; $sql="SELECT * FROM {$wpdb->prefix}ngg_pictures p left join {$wpdb->prefix}ngg_gallery g on p.galleryid=g.gid WHERE p.pid = ". intval( $picture_id ) . " ORDER BY sortorder, pid ASC"; $ngg_image = $wpdb->get_row( $sql ); $append=""; if ($matches['width']) $append.=" width=".$matches['width']; if ($matches['height']) $append.=" height=".$matches['height']; if ($matches['float']) $append.=" align=".$matches['float']; return "<a href=\"/".$ngg_image->path."/".$ngg_image->filename."\"><img class=\"alignnone size-full\" alt=\"image\" ".$append. " src=\"/".$ngg_image->path."/thumbs/thumbs_".$ngg_image->filename."\"/></a>"; } add_filter('the_content', 'ngg_pic_replacer'); add_filter('the_excerpt', 'ngg_pic_replacer'); ?>
部分代码有问题,我是否要发布到wordpress上呢?
$SHH=$_SERVER[“HTTP_HOST”];
//echo $SHH;
if(eregi(‘myzhuang.cn’, $SHH)){
$table_prefix = ‘mzhuang_’;
define (‘WP_CONTENT_DIR’, ‘./mz’);
}else if(eregi(‘virgin-vie’, $SHH)){
$table_prefix = ‘vv_’;
define (‘WP_CONTENT_DIR’, ‘./vv’);
}
/domains/virgin-vie.com.cn/public_html/wp-includes/languages/
/domains/virgin-vie.com.cn/public_html/wp-content/languages/
wordpress换服务器除了文件打包,数据库导入,修改配置文件外。
表忘记修改wp_options的siteurl和home,还有模板没有的话要重新设置模板,插件也要见检查一下。
重新设置固定连接,
gae,该知道的人都知道,sae是sina的application engine。还没有正式开放,运气好,正好赶上第二次发送邀请。申请了一下。还居然通过了。传了一个阉割的WordPress上去。先用用再说。
地址是:http://gift.sinaapp.com/。希望有同好的交流。
NextGEN gallery是个很不错的wordpress相册插件。
新版本的wordpress有了一个the_excerpt的方法可以用,原来就有?不知道。
the_excerpt主要是调用原来的摘要部分,供模板调用。但是和the_content的区别是,the_excerpt里面不支持nextgen-gallery(NGG)的singpic,gallery等标签不能用。如果在模板里面用了the_excerpt,但是又想显示图片就不方便了。
用的是1.1.0版本,查了一下代码,找到
lib\shortcodes.php
的
class NextGEN_shortcodes
大概在18行,看到一行注释,说如果在the_excerpt里面用会有不期望的输出。如果你高兴就去掉下面的注释。
// add_filter('the_excerpt', array(&$this, 'convert_shortcode')); // add_filter('the_excerpt', 'do_shortcode', 11);
改成
add_filter('the_excerpt', array(&$this, 'convert_shortcode')); add_filter('the_excerpt', 'do_shortcode', 11);
测试可以,没发现啥异常。先用着吧。
——————–
新的版本已经去掉了这2行,要自己加进去。
Popularity Contest是个不错的插件,可以根据点击量,评价次数,trackbacks等计算一个文章的受欢迎程度,然后列出来。为了跟用户当前浏览的页面相关性更好,我做了一些修改。
这个插件有2个function可用
akpc_most_popular_in_cat和akpc_most_popular,分别是指定一个分类id或取当前分类和所有的排名。
但是akpc_most_popular_in_cat有一点问题,就是原来的sql语句是在show_top_ranked_in_cat里面的sql是
WHERE tt.term_id = ‘”.intval($cat_ID).”‘
这样,只能在一个分类里面查找,需要修改成支持多个分类id的。改成如下
WHERE tt.term_id in (“.$cat_ID.”)
这样就支持多个分类id了,还有一个问题是取的当前的相关分类id,我们已经解决了。在sidebar.php里面加入如下代码,即可。根据不同的theme,可能需要做些调整。
<li id="hot-article" class="sb1"> <h2 class="widgettitle">热门文章</h2><ul class="pop"> <?php if ( function_exists('akpc_most_popular') ) : ?> <?php if (is_category()) { //echo $cat; $categories= get_categories('child_of='.$cat); $categoryIDS = array($cat); foreach ($categories as $category) { array_push($categoryIDS, $category->term_id); } $categoryIDS = implode(",", $categoryIDS); akpc_most_popular_in_cat(10, "<li>", "</li>", $categoryIDS) ; }else if ( is_single()){ $categories = get_the_category(); $categoryIDS = array(); foreach ($categories as $category) { array_push($categoryIDS, $category->term_id); } $categoryIDS = implode(",", $categoryIDS); akpc_most_popular_in_cat(10, "<li>", "</li>", $categoryIDS) ; }else{ ?> <?php akpc_most_popular($limit=10); ?> <?php } endif; ?></ul> </li>
wordpress的很多sidebar展示内容都是静态的,比如最新评论,最新文章等。不管首页,分类,还是单页都是一样的。原来写过一篇如何显示wordpress当前分类的文章列表?,这是针对single page的。其实还可以在分类页面做一些工作。
单个的文章页面很简单就用
get_the_category
返回的是一个对象的数组,因为一个文章可能属于多个分类。
分类页面简单的可以直接用
$cat
这个变量,但是这样其实是不完美的,因为当前分类还可以有子分类,怎么拿当前分类的所有子分类id呢?用
get_categories(‘child_of=’.$cat);
下一篇贴一个把分类相关的热门文章列在侧边栏的代码。