A-A+
wordpress建站必须要做的一些设置
在使用wordpress建站时需要做的一些修改,比如文章ID的不连续性,使用主题关键词的设置以及必备插件的安装,今天主要整理一下,以方便自己查阅使用。
一、文章不连续的更改
wp-config.php文件中添加:
- /** 禁用修改版。 */
- define('AUTOSAVE_INTERVAL', 120000000 ); // 设置自动保存间隔,单位是秒,默认60
- define('WP_POST_REVISIONS', false ); // 禁用文章修订功能 (完)
还要在后台 wp-admin/ 目录下的 post.php 和 post-new.php 文件中删除掉保存成草稿的代码,如果不删除掉,还是会产生ID号的。
post.php 删除以下代码:
- /* if ( $last = wp_check_post_lock( $post->ID ) ) {
- add_action('admin_notices', '_admin_notice_post_locked' );
- } else {
- $active_post_lock = wp_set_post_lock( $post->ID );
- if ( 'attachment' !== $post_type )
- wp_enqueue_script('autosave');
- } */
- //$title = $post_type_object->labels->edit_item;
- //$post = get_post($post_id, OBJECT, 'edit');
- //if ( post_type_supports($post_type, 'comments') ) {
- //wp_enqueue_script('admin-comments');
- //enqueue_comment_hotkeys_js();
- //}
post-new.php 注释掉 wp_enqueue_script('autosave'); 即可。
二、关键词设置:
单独关键词设置,位置:主题下:inc/functions/seo.php
原主题 SEO 的内容:
- $keywords = "";
- $tags = wp_get_post_tags($post->ID);
- foreach ($tags as $tag ) {
- $keywords = $keywords . $tag->name . ",";
- }
更改为:
- if (is_home() || is_page()) {
- // 将以下引号中的内容改成你的主页keywords
- $keywords = "WordPress, 博客, 编程,php,ludou";
- }
- elseif (is_single()) {
- // 填写自定义字段keywords时显示自定义字段的内容,否则使用文章tags作为关键词
- $keywords = get_post_meta($post->ID, "keywords", true);
- if($keywords == '') {
- $tags = wp_get_post_tags($post->ID);
- foreach ($tags as $tag ) {
- $keywords = $keywords . $tag->name . ", ";
- }
- $keywords = rtrim($keywords, ', ');
- }
- }
- elseif (is_category()) {
- $keywords = single_cat_title('', false);
- }
- elseif (is_tag()){
- $keywords = single_tag_title('', false);
- }
- $keywords = trim(strip_tags($keywords));
- }
三、安装插件:
1,Akismet
2,cos-html-cache
3,DB Cache Reloaded Fix
4, Disable Google Fonts
5,SyntaxHighlighter Evolved
6,WP-PostViews
很多年前一直用 wordpress,都会简单的模版修改了,但现在忘光了