记录日常点点滴滴,欢迎来到我的小站。

0%

这篇文章总结一下修改列表页面用到的hooks及修改page、custom post type、comments、media和user列表页的方法。最后奉上收集到的一些很有用的文章和代码。

了解列表页面的字段类型

打开文章列表,大致能看到以下内容

  • 批量操作的多选按钮(checkbox),通常在列表第一排
  • 标题下的编辑、删除等连接,这些链接称为row actions
  • 普通的字段,例如作者、分类等,它们只能展示简单结果
  • 可排序的字段,例如评论数,发布日期等

这些都是WordPress内置的栏目字段。

阅读全文 »

由于误删除,将开发证书给弄没了,导致Certificates中更新的证书都提示此证书是由未知颁发机构签名的,不能实机调试,解决办法是重新下载AppleWWDRCA.cer

地址是:http://developer.apple.com/certificationauthority/AppleWWDRCA.cer
下载后运行自动导入到钥匙串中,一切就正常了。

如果出现 Command /usr/bin/codesign failed with exit code 1
检查钥匙串中,系统标签中是否也存在开发者证书,如果存在就删除掉,因为冲突了。

query_post的功能的确强大,可以使用它来自定义你想要调用的文章,现在要说的是通过它来实现文章的分页,在我的主题中我后台设置的是每一页10篇文章,但在我图片这个分类中我想显示9张图片,这就要用到以下代码

1
2
3
4
5
6
7
<?php
query_posts('showposts=9&cat=64');
if (have_posts()) : while (have_posts()) : the_post();?>
<div class="pic" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
.....
</div>
<?php endwhile;endif; ?>
阅读全文 »

1、打开httpd.conf,查找Listen:80,在下面一行加入Listen:8080;

2、查找#Include conf/extra/httpd-vhosts.conf,将此行前面的#去掉;

3、打开httpd.conf文件目录下面的extra文件夹下面的httpd-vhosts.conf文件;

4、查找NameVirtualHost *:80,在下面一行增加NameVirtualHost *:8080;

阅读全文 »

1
2
3
4
5
name: liyuxingbaobei
version: 1
handle:
- rewrite: if(!is_dir() && !is_file()) goto "index.php?%{QUERY_STRING}"
- errordoc: 404 /404.php

追加下面三行即可。

一, 在Storage中建好一个叫wordpress的domain 在SAE上创建应用,安装WordPress for SAE版本的时候会提示要先在Storage中建个wordpress的domain。

二, 在应用的根目录,创建sae.php文件
1).先用svn的工具TortoiseSVN把应用的代码全部checkout到本地。
2).在应用的根目录,创建sae.php文件
代码如下:

1
2
3
4
5
6
7
<?php
/* 在SAE的Storage中新建的Domain名,比如“wordpress”*/
define('SAE_STORAGE',wordpress);
/* 设置文件上传的路径和文件路径的URL,不要更改 */
define('SAE_DIR', 'saestor://'.SAE_STORAGE.'/uploads');
define('SAE_URL', 'http://'.$_SERVER['HTTP_APPNAME'].'-'.SAE_STORAGE.'.stor.sinaapp.com/uploads');
?>

三, 修改wp-includes/functions.php文件
1).

1
require( ABSPATH . WPINC . '/option.php' );

前添加一行:

1
include( ABSPATH . '/sae.php' ); //调用SAE的Storage文件域名设置 //for SAE

2).注释掉如下代码,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*** Step 1: include sae.php ***/
include( ABSPATH . '/sae.php' ); //添加这一行。调用SAE的Storage文件域名设置
require( ABSPATH . WPINC . '/option.php' );
前添加

/*** Step 2: 替换代码 ***/
/*
$wrapper = null;

// Strip the protocol.
if (wp_is_stream ( $target )) {
list ( $wrapper, $target ) = explode ( '://', $target, 2 );
}

// From php.net/mkdir user contributed notes.
$target = str_replace ( '//', '/', $target );

// Put the wrapper back on the target.
if ($wrapper !== null) {
$target = $wrapper . '://' . $target;
}
*/

//替换为以下代码
// from php.net/mkdir user contributed notes
if (substr ( $target, 0, 10 ) == 'saestor://') {
return true;
}
$target = str_replace ( '//', '/', $target );

/*** Step 3: 添加代码 ***/
$dir = SAE_DIR; //添加这一行
$url = SAE_URL; //添加这一行
$basedir = $dir;

/*** Step 4: 添加代码 ***/
//添加如下代码块
if ( !function_exists('utf8_encode') ) {
function utf8_encode($str) {
$encoding_in = mb_detect_encoding($str);
return mb_convert_encoding($str, 'UTF-8', $encoding_in);
}
}

//在这前面添加上述代码
/**
* Send a HTTP header to limit rendering of pages to same origin iframes.
*
* @since 3.1.3
*
* @see https://developer.mozilla.org/en/the_x-frame-options_response_header
*/

四, 修改wp-admin/includes/file.php

1
2
3
4
5
/*** 注释如下代码 ***/
// Set correct file permissions.
$stat = stat ( dirname ( $new_file ) );
$perms = $stat ['mode'] & 0000666;
@ chmod ( $new_file, $perms );

一、IE8报下面错误,解决办法:
网页错误详细信息
消息: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
行: 0
字符: 0
代码: 0
1、查看是否有未关闭的html标签,比如

而没有

2、是否在页面未加载完前js代码操作了body里的元素,将相关js代码移到后面
3、是否在代码中添加了addthis分享js
4、是否IE8打开了兼容性视图
(我的页面出错就是3、4两个原因导致的)

阅读全文 »

禁止普通用户通过sudo su命令进入root模式的方法(在root模式下操作):

1
2
# chmod 777 /etc/sudoers
# vi /etc/sudoers

在里面添加一行

1
your_username ALL=(ALL:ALL) ALL,!/bin/su

这里的your_username 想要禁止的用户名

1
2
:wq (保存并退出)
# chmod 0440 /etc/sudoers

PS:千万别忘了把默认账户添加密码