去除后台标题中的—WordPress

  1. 在 functions 文件中添加
    1. add_filter('admin_title', 'wp_custom_admin_title', 10, 2);
    2. function wp_custom_admin_title($admin_title, $title){
    3. return $title.' ‹ '.get_bloginfo('name');
    4. }

删除或修改后台面板的版权或版本信息

  1. 在 functions 文件中添加
    function remove_footer_admin () {
     echo '陈爽大师兄。';
    }
    add_filter('admin_footer_text', 'remove_footer_admin');
    

更改登陆页面LOGO

  1. 在 functions 文件中添加

    //更改登陆页面LOGO
    function custom_loginlogo() {
     echo '<style type="text/css">
     h1 a {background-image: url('.get_bloginfo('template_directory').'/logo.png) !important; }
     </style>';
     }
     add_action('login_head', 'custom_loginlogo');
    
  2. 在主题主目录放一张名为 logo.png 的图片。

添加上传网站LOGO或图片功能

  1. 在 functions 文件中添加

    class ClassicOptions {            
         function getOptions() {         
             $options = get_option('classic_options');            
             if (!is_array($options)) {          
                 $options['chenshuang_logo'] = '';      
                 update_option('classic_options', $options);         
             }   
             return $options;      
         }   
         function init() {   
             if(isset($_POST['classic_save'])) {   
                 $options = ClassicOptions::getOptions();   
                 $options['chenshuang_logo'] = stripslashes($_POST['chenshuang_logo']);      
                 update_option('classic_options', $options);   
             } else {   
                 ClassicOptions::getOptions();         
             }   
             add_theme_page("主题设置", "主题设置", 'edit_themes', basename(__FILE__), array('ClassicOptions', 'display'));         
         }   
         function display() {        
             $options = ClassicOptions::getOptions(); ?>         
             <form method="post" enctype="multipart/form-data" name="classic_form" id="classic_form">         
             <div class="wrap">         
             <h2><?php _e('主题设置'); ?></h2>   
             <p>   
             <label>   
                 <input type="text" size="80"  name="chenshuang_logo" id="chenshuang_logo" value="<?php echo($options['chenshuang_logo']); ?>"/>   
                 <input type="button" name="upload_button" value="上传" id="upbottom"/>   
             </label>   
             </p>                           
             <p class="submit">    
                 <input type="submit" name="classic_save" value="<?php _e('保存设置'); ?>" />         
             </p>         
         </div>         
     </form>         
     <?php         
         }       
     }         
     add_action('admin_menu', array('ClassicOptions', 'init')); 
     wp_enqueue_script('my-upload', get_bloginfo( 'stylesheet_directory' ) . '/js/upload.js');   
     //加载上传图片的js(wp自带)   
     wp_enqueue_script('thickbox');   
     //加载css(wp自带)   
     wp_enqueue_style('thickbox');
    
  2. 新建一个 upload.js 文件,上传代码 ```php jQuery(document).ready(function() { //upbottom为上传按钮的id
    jQuery(‘#upbottom’).click(function() {

     //chenshuang_logo为文本域   
     targetfield = jQuery(this).prev('#chenshuang_logo');
     tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
     return false;
    

    });

    window.send_to_editor = function(html) {

     imgurl = jQuery('img', html).attr('src');
     jQuery(targetfield).val(imgurl);
     tb_remove();
    

    }

});


3. 在前台文件适当的位置调用函数
```php
<?php 
 $logo=get_option('classic_options');
 $logo_url=$logo['ashu_logo']; 
?>

去掉后台左上角的图标logo

  1. 在 functions 文件中添加
    /**移除后台顶部左上角图标*/
    function annointed_admin_bar_remove() {
     global $wp_admin_bar;/* Remove their stuff */
     $wp_admin_bar->remove_menu('wp-logo');
     }add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
    

美化登录界面

  1. 在 functions 文件中添加

    //美化WordPress登录界面
    function custom_login_logo() {
     echo '<link rel="stylesheet" id="wp-admin-css" href="'.get_bloginfo('template_directory').'/wplogin.css" type="text/css" />';
     }
     add_action('login_head', 'custom_login_logo');
    
  2. 新建一个 wplogin.css 文件 ```css body, textarea { font-size: 14px; font-family: “Microsoft Yahei”, 宋体, PMingLiU, Verdana, Arial, Helvetica, sans-serif !important; }

input { font-size: 14px; font-family: Tahoma, Arial, sans-serif !important; }

body { width: 100%; height: 100%; background-image: url(‘logo.png’); //背景图片 -moz-background-size: 100% 100%; -o-background-size: 100% 100%; -webkit-background-size: 100% 100%; background-size: 100% 100%; / -moz-border-image: url(‘logo.png’); / background-repeat: no-repeat\9; background-image: none\9; }

.login h1 a { background-image: url(‘logo.png’) !important; //登录logo background-size: 170px 35px; background-position: top center; background-repeat: no-repeat; width: 170px; margin: auto; margin-top: 35px; height: 35px; text-indent: -9999px; overflow: hidden; padding-bottom: 15px; display: block; }

login {

width: 320px;
background: rgba(0, 0, 0, 0.2);
padding: 0 20px 100% 12px;
margin: auto;
top: 0px;
left: 0px;
position: fixed;
box-shadow: 0px 0px 5px 0px #333;

}

.login form { margin-left: 8px; padding: 26px 24px 46px; font-weight: normal; background: rgba(255, 255, 255, 0.2); border: none; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: #000 0 0px 10px -1px; }

loginform {

-webkit-border-radius: 0px;
border-radius: 0px;

}

.login form .input, .login input[type=”text”] { color: #555; font-weight: 200; font-size: 24px; line-height: 1; width: 100%; padding: 5px; margin-top: 2px; margin-right: 6px; margin-bottom: 16px; border: 1px solid #FFF; background: #FFF !important; outline: 0; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; }

.login form .input, .login input[type=”text”] { font-size: 17px; padding-bottom: 11px; padding-top: 11px; text-indent: 3px; }

.login form .input, .login input[type=”text”] { border: 2px solid #DCE4EC; }

input.button-primary { margin-top: 8px; border: #000; font-weight: bold; text-shadow: #FFF 0 0px 10px; }

.login .button-primary { font-size: 14px!important; line-height: 22px; padding: 8px 117px; border-radius: 0px; }

input.button-primary { background: rgba(255, 255, 255, 0.5); color: #000; }

input.button-primary:hover, input.button-primary:focus { background: rgba(255, 255, 255, 0.8); color: #000; }

input.button-primary:active { background: rgba(255, 255, 255, 0.2); color: #000; }

.login form .forgetmenot { font-weight: normal; float: none; margin-top: -10px; }

.login #nav, .login #backtoblog { text-shadow: none; float: rightright; margin: 0 30px 0 0px; padding: 16px 0px 0 20px; }

.login #nav a, .login #backtoblog a { color: #FFF!important; text-decoration: none; }

.login #nav a:hover, .login #backtoblog a:hover { color: #444!important; text-decoration: none; }

div.error, .login #login_error { display: none; }

div.updated, .login .message { background-color: #E0FFE1; border-color: #ACE655; }

.wumii-footer { display: none !important; }



<a name="EJSlG"></a>
#### 调用最新留言
该代码直接调用数据库显示一份最新留言,其中 LIMIT 10限制留言显示数量,绿色部份则是每条留言的输出样式。
```php
<?php
  global $wpdb;
$sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,30) AS com_excerpt
  FROM $wpdb->comments
  LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
                                   $wpdb->posts.ID)
  WHERE comment_approved = ’1′ AND comment_type = ” AND
  post_password = ”
  ORDER BY comment_date_gmt DESC
  LIMIT 10″;
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;   foreach ($comments as $comment) {undefined
  $output .= “n<li>”.strip_tags($comment->comment_author)
  .”:” . ” <a href=”" . get_permalink($comment->ID) .
  “#comment-” . $comment->comment_ID . “” title=”on ” .
  $comment->post_title . “”>” . strip_tags($comment->com_excerpt)
  .”</a></li>”;
  }   $output .= $post_HTML;
echo $output;?>

调用含gravatar头像的评论输出

<?php
  global $wpdb;
$sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,10) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = ’1′ AND comment_type = ” AND comment_author != ‘郑 永’ AND post_password = ” ORDER BY comment_date_gmt DESC LIMIT 10″;
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
foreach ($comments as $comment) {undefined
  $output .= “\n<li>”.get_avatar(get_comment_author_email(‘comment_author_email’), 18). ” <a href=\”" . get_permalink($comment->ID) . “#comment-” . $comment->comment_ID . “\” title=\”" . $comment->post_title . ” 上的评论\”>”. strip_tags($comment->comment_author) .”: “. strip_tags($comment->com_excerpt) .”</a></li>”;
                                }
$output .= $post_HTML;
$output = convert_smilies($output);
echo $output;
?>

上面代码把comment_author的值改成你的ID,18是头像大小,10是评论数量。

去评论者链接的评论输出

<?php
global $wpdb;
$sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,14) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
$wpdb->posts.ID)
WHERE comment_approved = ’1′ AND comment_type = ” AND
post_password = ”
ORDER BY comment_date_gmt DESC
LIMIT 10″;
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
foreach ($comments as $comment) {undefined
$output .= “\n<li>”.strip_tags($comment->comment_author)
.”:” . ” <a href=\”" . get_permalink($comment->ID) .
“#comment-” . $comment->comment_ID . “\” title=\”on ” .
$comment->post_title . “\”>” . strip_tags($comment->com_excerpt)
.”</a></li>”;
}
$output .= $post_HTML;
echo $output;?>