1.不同分类输出不同模板

先在当前模板目录下建立一个 category 目录,然后比如你要给 slug 为 default 的分类专门建立模板,那么就在 category 目录下创建一个名为 default.php 的文件,这样程序在访问 default 分类时会自动调用这个模板文件。

使用 $this->categories 和 $this->category 这两个变量就可以满足你的需要了,不过需要你自己手动循环输出。你可以 print_r 一下这两个变量,看看它们的结构。

2.适用于所有有分类区别的页面

<?php if ($this->category == "分类A的缩略名"): ?>
// 这里是分类A的样式
<?php elseif ($this->category == "分类B的缩略名"): ?>
// 这里是分类B的样式
<?php else: ?>
// 这里是分类C的样式
<?php endif; ?>

附:分类名称调用

<?php $this->category(','); ?> //带连接的分类名称,逗号为多分类时的间隔符
<?php $this->category(',', false); ?> //不带连接的纯粹的分类名称,类似评论者名称调用, $comments->author('', false) 显示不带连接的名称

作者信息

<?php $this->author() ?> //作者名称
<?php $this->author->permalink(); ?> //作者文章列表连接
<?php $this->author->url(); ?>
<?php $this->author('url'); ?> //作者主页
<?php $this->author->mail(); ?>
<?php $this->author('mail'); ?> //作者邮箱
<?php $this->author->gravatar(); ?> //作者头像

分类信息

<?php echo $this->category; ?> //分类缩略名
<?php $this->category(); ?> //带连接的分类名称
<?php $this->category(',', false); ?> //不带连接的分类名称

评论者信息

<?php $comments->author(); ?> //带连接的作者名
<?php $comments->author('', false); ?> //不带连接的作者名

往往我们对拿到手的VPS都想知道性能怎么样,今天就来整理下关于测试LinuxVPS性能的文章:

需要使用ROOT登陆SSH进行操作,使用Xshell之类软件。

一、CPU信息及性能查看

先使用命令,得到你的CPU信息,你也可以在探针里面看,探针里面比较详细。

cat /proc/cpuinfo

CPU查询:www.anandtech.com/Bench - www.cpubenchmark.net

- 阅读剩余部分 -

今天买了个VPS,没有后台面板修改密码的,只有用软件修改了。

第一步:输入命令 passwd,按下Enter键,会出现:

changing password for user root.
New UNIX password:

第二步:输入你的新密码,按下Enter键,会出现:

Retype new UNIX password:

第三步,重复输入你的密码,按下Enter键:

修改成功!

在服务器安装了LNMP,如果想在 honglajiao.net/wordpress/ 类似的目录下,再安装一个WP博客,那原来的 nginx 伪静态规则就不行了,那只对根目录有效,还得配置二级子目录的nginx 伪静态规则,如下:

location /wordpress/ {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /wordpress/index.php;
}
}

把上面的内容写到一个文件,如 wp.conf,然后把这个 wp.conf 包含在相应站点的 nginx 配置文件中,就可以实现二级目录建WP站的伪静态。

- 阅读剩余部分 -