A-A+

wordpress建站必须要做的一些设置

2023年05月13日 PHP开源系统 评论 1 条 阅读 0 views 次

在使用wordpress建站时需要做的一些修改,比如文章ID的不连续性,使用主题关键词的设置以及必备插件的安装,今天主要整理一下,以方便自己查阅使用。

一、文章不连续的更改

wp-config.php文件中添加:

  1. /** 禁用修改版。 */  
  2. define('AUTOSAVE_INTERVAL', 120000000 ); // 设置自动保存间隔,单位是秒,默认60   
  3. define('WP_POST_REVISIONS', false ); // 禁用文章修订功能 (完)  

还要在后台 wp-admin/ 目录下的 post.php 和 post-new.php 文件中删除掉保存成草稿的代码,如果不删除掉,还是会产生ID号的。

post.php 删除以下代码:

  1. /* if ( $last = wp_check_post_lock( $post->ID ) ) { 
  2. add_action('admin_notices', '_admin_notice_post_locked' ); 
  3. } else { 
  4. $active_post_lock = wp_set_post_lock( $post->ID ); 
  5.  
  6. if ( 'attachment' !== $post_type ) 
  7. wp_enqueue_script('autosave'); 
  8. } */  
  9.   
  10. //$title = $post_type_object->labels->edit_item;  
  11. //$post = get_post($post_id, OBJECT, 'edit');  
  12.   
  13. //if ( post_type_supports($post_type, 'comments') ) {  
  14. //wp_enqueue_script('admin-comments');  
  15. //enqueue_comment_hotkeys_js();  
  16. //}  

post-new.php 注释掉 wp_enqueue_script('autosave'); 即可。

二、关键词设置:

单独关键词设置,位置:主题下:inc/functions/seo.php

原主题 SEO 的内容:

  1. $keywords = "";   
  2. $tags = wp_get_post_tags($post->ID);  
  3. foreach ($tags as $tag ) {  
  4. $keywords = $keywords . $tag->name . ",";  
  5. }  

更改为:

  1. if (is_home() || is_page()) {  
  2. // 将以下引号中的内容改成你的主页keywords  
  3. $keywords = "WordPress, 博客, 编程,php,ludou";  
  4. }  
  5. elseif (is_single()) {  
  6. // 填写自定义字段keywords时显示自定义字段的内容,否则使用文章tags作为关键词  
  7. $keywords = get_post_meta($post->ID, "keywords", true);  
  8. if($keywords == '') {  
  9. $tags = wp_get_post_tags($post->ID);   
  10. foreach ($tags as $tag ) {   
  11. $keywords = $keywords . $tag->name . ", ";   
  12. }  
  13. $keywords = rtrim($keywords, ', ');  
  14. }  
  15. }  
  16. elseif (is_category()) {  
  17. $keywords = single_cat_title('', false);  
  18. }  
  19. elseif (is_tag()){  
  20. $keywords = single_tag_title('', false);  
  21. }  
  22. $keywords = trim(strip_tags($keywords));  
  23. }  

三、安装插件:

1,Akismet

2,cos-html-cache

3,DB Cache Reloaded Fix

4, Disable Google Fonts

5,SyntaxHighlighter Evolved

6,WP-PostViews

标签:

1 条留言  访客:1 条  博主:0 条

  1. koobai

    很多年前一直用 wordpress,都会简单的模版修改了,但现在忘光了

给我留言